Java两种读取输入的方式
作者:
正经龙 | 来源:发表于
2019-08-19 16:13 被阅读0次
- 使用Scanner类
- 使用BufferReader类
public class InputMethod {
public static void main(String args[]) throws IOException {
//1. use Scanner
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
float b = sc.nextFloat();
String c = sc.next();
//2. use BufferedReader
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str = bf.readLine();
int s = bf.read();
}
}
本文标题:Java两种读取输入的方式
本文链接:https://www.haomeiwen.com/subject/xtqesctx.html
网友评论