IO流 p8 标准输入输出流
标准输入输出流
| 流 | 编译类型 | 运行类型 | 默认设备 |
|---|---|---|---|
| System.in 标准输入 | InputStream | BufferedInputStream | 键盘 |
| System.in 标准输出 | PrintStream | PrintStream | 显示器 |
代码演示:
import java.util.Scanner;
/**
* @author: 86199
* @date: 2023/5/7 16:11
* @description:
*/
public class InputAndOutput {
public static void main(String[] args) {
//System类 的public final static InputStream in = null;
//System.in 编译类型 InputStream
//System.in 运行类型 BufferedInputStream
//表示标准输入 键盘
System.out.println(System.in.getClass());
//System.out: public final static PrintStream out = null;
//System.out 编译类型 PrintStream
//System.out 运行类型 PrintStream
//表示的时标准输出 显示器
System.out.println(System.out.getClass());
System.out.println("Hello World");
Scanner scanner = new Scanner(System.in);
System.out.println("输入内容:");
String next = scanner.next();
System.out.println("next = " + next);
}
}

浙公网安备 33010602011771号