0
点赞
收藏
分享

微信扫一扫

读取用户键盘输入的方法


最简单的:

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();


举报

相关推荐

0 条评论