next 一个字符串
public class demo02 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入数据:");
String str = scanner.next();
System.out.println("输出的数据为:"+str);
scanner.close();
}
}
nextline 多个字符串
public class demo01 {
public static void main(String[] args){
//从键盘接收数据
Scanner scanner = new Scanner(System.in);
System.out.println("请输入数据:");
String str = scanner.nextLine();
System.out.println("输出的内容为"+str);
scanner.close();
}
}