java怎么输入整数
如果是想通过键盘,输入整数,可以这么写:
public class TestInput {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println('please Input an integer');
Long inputNumber = Long.valueOf(br.readLine());
System.out.println('you input: 123' + inputNumber);
}catch (Exception e){
System.out.println('invalid input!');
}
}
}
赞0
踩0