public static void main(java.lang.String[] args) {
try {
while (true) {
char c = (char) System.in.read();
if (c == '\r'){
break;
}
String i = new String(new char[] {c});
int t = Integer.parseInt(i); System.out.println(t + "");
}
} catch (Exception e) {
System.out.println("请输入数字");
}
}
try {
while (true) {
char c = (char) System.in.read();
if (c == '\r'){
break;
}
String i = new String(new char[] {c});
int t = Integer.parseInt(i); System.out.println(t + "");
}
} catch (Exception e) {
System.out.println("请输入数字");
}
}
public class snow {
public static void main(String args[]) throws IOException {
int d,b;
String c;
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter v of c:");
c=keyin.readLine(); \\这里可输入多个数(其实是字符)
d=Integer.parseInt(c);
b=d+18;
System.out.println("b="+b);
}
}
这样应该就没有问题了