常见对象_Scanner的概述和构造方法原理

来源:互联网 发布:软件测试sql笔试题 编辑:程序博客网 时间:2024/04/25 21:29
package cn.itcast_01;/* * Scanner:用于接收键盘录入数据。 *  * 前面的时候: * A:导包 * B:创建对象 * C:调用方法 *  * System类下有一个静态的字段: * public static final InputStream in;标准的输入流,对应着键盘录入。 *  * InputStream is = System.in; *  * class Demo{ * public static final int x = 10; * public static final Student s = new Student(); * } * int y = Demo.x; * Student s = Demo.s; *  * 构造方法: * Scanner(InputStream source) ; */import java.util.Scanner;public class ScannerDemo {public static void main(String[] args) {//创建对象Scanner sc = new Scanner(System.in);int x = sc.nextInt();System.out.println("X:"+x);}}

0 0
原创粉丝点击