Input and output of basic data operations in java

  • Java uses a predefined Scanner class object to implement the data entered by the user's keyboard
    then. It needs to be imported before use. Scanner belongs to the java.util package. To use this class, you need to import the import statement into the program.
package 基本数据操作;
/*数据的输入和输出*/
import java.util.Scanner;
public class Test_1 {
    
    
	public static void main(String[] args) {
    
    
		Scanner val = new Scanner(System.in);/*创建Scanner对象*/
		System.out.println("请输入你的年龄:");
		String name = val.nextLine();
		val.close();/*关闭scanner对象*/
		System.out.println("从键盘得到你的年龄是:"+name);
	}

}

Let me tell you a novice shortcut key, enter (syso) and then press and hold Alt+/ to quickly associate the output statement.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324090653&siteId=291194637
Recommended