int id;
float grade;
String name;
Scanner z= new Scanner(System.in);
System.out.println("Give the id:\n");
id=z.nextInt();
System.out.println("your id is :"+id+"\n");
System.out.println("Give the name:");
name=z.nextLine();
System.out.println("your name is :"+name);
System.out.println("Give the grade:\n");
grade=z.nextFloat();
问题是这样的。它输入整数,但是当涉及到字符串时,它会打印“给出名称”,但它不会等到我输入一些东西,它会跳到下一条指令。
为什么?