获取键盘输入信息常用的两种方法

1.Scanner

1 Scanner  sc = new Scanner(System.in);
2 String s1 = sc.next();
3 String s2 = sc.nextLine();
4 int a = sc.nextInt();

2.BufferedReader

1 BufferedReader input = new BafferedReader(new InputStreamReader(System.in));
2 int a = input.read();//读取一个字符
3 String s = input.readLine();

 

posted @ 2020-07-24 14:17  德华。  阅读(517)  评论(0编辑  收藏  举报