public class demo01 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("使用next方式接受:");
if (scanner.hasNext()){
String str = scanner.next();
System.out.println("输出的内容为:"+str);
}
scanner.close();
}
}
public class Demo02 {标签:scanner,用户,System,Scanner,String,交互,public,out From: https://www.cnblogs.com/LinQWblog/p/17089877.html
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("使用next方式接受:");
if (scanner.hasNextLine()){
String str = scanner.nextLine();
System.out.println("输出的内容为:"+str);
}
scanner.close();
}
}