1,建一个Scanner对象 Scanner scanner = new Scanner(System.in); 2,调用scanner对象的方法 String name = scanner.next();