Modify the Student class in Listing 8.2 so that it implements the Comparable interface. Define the compareTo method to order Student objects based on the value in studentNumber. In a main method create an array of at least 5 Student objects, sort them using Arrays.sort, and output the students. They should be listed by ascending student number. Next, modify the compareTo method so it orders Student objects based on the lexicographic ordering of the name variable. Without modification to the main method, the program should now output the students ordered by name.
This solution uses the class Student2 to distinguish it from the listing in the textbook. The solution is similar to Listing 8.18 and Listing 8.19.
See the code in Student2.java, StudentDemo.java
You might also like to view...
MC The
a) alphanumeric keys. b) control key is pressed. c) function key is pressed. d) All of the above.
If a feature is found in the C language, is that feature in C++? Is the reverse true?
What will be an ideal response?
WEP protects _______________ by scrambling the wireless data as it is transmitted.
Fill in the blank(s) with the appropriate word(s).
You must delete all unused placeholders on a slide since they will show when you run the slide show
Indicate whether the statement is true or false