InputMismatchException when using Sacnner nextLine for String [duplicate]
问题 This question already has answers here : Scanner is skipping nextLine() after using next() or nextFoo()? (19 answers) Closed 3 years ago . This is my code import java.io.*; import java.util.*; class student { String name; int age; float cgpa; } public class getdata { public static void main(String args[]) throws IOException { Scanner in=new Scanner(System.in); int n; n=in.nextInt(); student[] s=new student[n]; for(int i=0;i<n;i++) { try { s[i]=new student(); s[i].name=in.nextLine(); in