import itcast.cm.bean.Student;
import java.util.Comparator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class Demo6 {
public static void main(String[] args) {
Set<Student> set = new TreeSet<>(new Comparator<Student>() {
public int compare(Student s1, Student s2){
int num = s1.getSum()- s2.getSum();
return num == 0 ? 1 : num;
}
});
Scanner sc = new Scanner(System.in);
System.out.println("请输入信息:");
while(true) {
String line = sc.nextLine();
if("quit".equals(line));
break;
String[] arr = line.split(",");
set.add(new Student(arr[0], Integer.parseInt(arr[1]), Integer.parseInt(arr[2]),
Integer.parseInt(arr[3])));
}
System.out.println("请输入学生信息:");
for (Student student : set) {
System.out.println(student);
}
}
}
第23行有什么错误?为什么eclipse也没有提示.
|