JOptionPane类中的方法挺好的。 可以看看SDK里面的帮助。而在jdk15.0以后有了新的方法来代替JOptionPane Console Input Prior to JDK 5.0, there was no Scanner class. Use JOptionPane.showInputDialog instead.5.0 Scanner in = new Scanner(System.in); System.out.print(prompt); int n = in.nextInt(); double x = in.nextDouble(); String s = in.nextLine(); 1.4 String input = JOptionPane.showInputDialog(prompt); int n = Integer.parseInt(input); double x = Double.parseDouble(input); s = input;
可以看看SDK里面的帮助。而在jdk15.0以后有了新的方法来代替JOptionPane
Console Input
Prior to JDK 5.0, there was no Scanner class. Use JOptionPane.showInputDialog instead.5.0
Scanner in = new Scanner(System.in);
System.out.print(prompt);
int n = in.nextInt();
double x = in.nextDouble();
String s = in.nextLine(); 1.4
String input = JOptionPane.showInputDialog(prompt);
int n = Integer.parseInt(input);
double x = Double.parseDouble(input);
s = input;
}
improt java.lang.* class{
String a = System.in.read(); //System.in的read方法可能抛出异常(java.io.IOException)
}
还用这些落后的啊
用Scanner
自己看api去
api中说的很清楚