Question: In my java program they are asking me to use both the compareTo method as well as one other method in order to sort all

In my java program they are asking me to use both the compareTo method as well as one other method in order to sort all the books in a catalog based on their title and I don't know how. This is what is suppose to be written in one of the classes: You will need to write the code for the compareTo method. This method should have one parameter of Book type. The order of the books is based on the alphabetical order of the title. Note that in order to have this method, your Book class should implement the Comparable interface. In addition, in the book catalog class it says : sortByTitle - this method sorts all the books based on title. Finally, in the main class, where I have made a menu for the user to choose what they want to do, for the sort option it says this : For the menu "Sort all the books based on title", you can call Collections.sort method to sort all the books in the list. Make sure you implement compareTo method correctly.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!