今天记录一下java中接收从控制台输入的数据 java输入语法 Scanner sc = new Scanner(System.in); 输入int变量: int n; n = sc.nextInt(); System.out.println(n); 输入字符串变量 String s; s = sc.next(); //读到空格结束 s = sc.nextLine(); //读到回车结束 sc.next()执行结果 sc.nextLine()执行结果