Java 读取控制台的输入,java读取控制台,Java语言中从标准输入
分享于 点击 7281 次 点评:220
Java 读取控制台的输入,java读取控制台,Java语言中从标准输入
Java语言中从标准输入(如键盘)读取数据的方法
import java.util.Scanner;public class InputExp { public static void main(String[] args) { String name; int age; Scanner in = new Scanner(System.in); // Reads a single line from the console // and stores into name variable name = in.nextLine(); // Reads a integer from the console // and stores into age variable age=in.nextInt(); in.close(); // Prints name and age to the console System.out.println("Name :"+name); System.out.println("Age :"+age); }}
用户点评