您的位置:首页 > 其它

读取用户键盘输入的方法

2006-01-10 21:50 253 查看
最简单的:
BufferedReader br =
new BufferedReader(
new InputStreamReader(System.in));
String s=in.readLine();
      //从输入流in中读入一行,并将读取的值赋值给字符串变量s
      System.out.println("Input value is: "+s);
      int i = Integer.parseInt(s);//转换成int型
JDK1.5 中新提供的:
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐