import javax.swing.*;
public class A extends JFrame{
public static void main(String args[]){
int input2;
boolean Int = false; while(!Int){
String input = JOptionPane.showInputDialog("Enter a integer");
input2 = Integer.parseInt(input);
if(input2 < 3){
Int = false;
}
else{
Int = true;
System.out.println("good"); }
}
System.exit(0); }
}
public class A extends JFrame{
public static void main(String args[]){
int input2;
boolean Int = false; while(!Int){
String input = JOptionPane.showInputDialog("Enter a integer");
input2 = Integer.parseInt(input);
if(input2 < 3){
Int = false;
}
else{
Int = true;
System.out.println("good"); }
}
System.exit(0); }
}
public class A{
public static void main(String args[]){
int input2, input4; String input = JOptionPane.showInputDialog("Enter a integer");
input2 = Integer.parseInt(input); boolean Int = false;
if(input2 < 3){
while(!false){
String input2 = JOptionPane.showInputDialog("Enter a integer");
} }
else{
Int = true;
System.out.print("good");
}System.exit(0);
}
}
虽然是不对,但是我总是不知道为什么这样,思路是错误的
public class A
{
public static void main(String args[])
{
int input2;
//boolean Int = false;
int Int=0;
while(Int==0)
{
String input = JOptionPane.showInputDialog("Enter a integer");
try{
input2 = Integer.parseInt(input);
if(input2 < 3)
{
Int =0;
}
else
{
Int = 1;
System.out.println("good"); }
}
catch(NumberFormatException e)
{}//校验输入是否为整数
//System.exit(0);放在此处无论输入什么将退出
}
System.exit(0);
}
}