20165333 The tenth week after class

2. In data structures and algorithms, sorting is a very important operation. There are two ways to allow a class to be sorted:

  • There is a source code of a class, sort a member variable, let the class implement the Comparable interface, and call Collection.sort(List)
  • If there is no source code of the class, or multiple sorting, create a new class, implement the Comparator interface and call Collection.sort(List, Compatator)

For the following Student class, use Comparator programming to complete the following functions:

  1. Create a new student list in the test class StudentTest, including two students before and after oneself and student number, a total of 5 students, and give the running results (before sorting, after sorting)
  2. Sort these 5 students in increasing order by student number and total score, and submit the codes of two Comparators
  3. Submit code to Code Cloud after class

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325445970&siteId=291194637