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); } }
本文作者:凉白茶
本文链接:https://www.cnblogs.com/zh-Note/p/17455318.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步