⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2.36returntest.java

📁 JAVA程序设计的源代码
💻 JAVA
字号:
import javax.swing.JOptionPane;
public class ReturnTest{
public static void main (String []args){
String temp=JOptionPane.showInputDialog("Input a positive integer:");    //提示用户输入一个正整数
int i=0;
try{
i=Integer.parseInt(temp);
}
catch(Exception e){    //异常信息提示
JOptionPane.showMessageDialog(null,"Error! You should input a integer!","Error",JOptionPane.ERROR_MESSAGE); 
return;    //退出
}
if(i<=0){    //错误信息提示
JOptionPane.showMessageDialog(null,"Error! i<=0!","Error",JOptionPane.ERROR_MESSAGE);
return; 
}
else{
JOptionPane.showMessageDialog(null,"The value of i is valid!","Success",JOptionPane.INFORMATION_MESSAGE);
}
JOptionPane.showMessageDialog(null,"I am  here for testing! \n You have input a valid value!","Success",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);    //退出整个程序
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -