public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int iteam = sc.nextInt();
Student[] students = new Student[iteam];
int id;
String name;
String city, s_city;
double marks, s_marks;
for (int i = 0; i < iteam; i++) {
id = sc.nextInt();
name = sc.nextLine();
city = sc.nextLine();
marks = sc.nextDouble();
students[i] = new Student(id, name, city, marks);
}
}
我有一个错误“Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextDouble(Unknown Source)"
我也尝试使用 next() 但存在相同的错误。我还导入了 java.util.Scanner。
哆啦的时光机
慕婉清6462132
心有法竹
相关分类