Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

When comparing two Issue objects, you need to check both volume and number value

ID: 3553326 • Letter: W

Question

When comparing two Issue objects, you need to check both volume and number values. Under what conditions, the compareTo() should return -1? 0? and 1?

Basically i'm asking when you have an object that needs to be sorted by an int volume and int number. How would I implement the compareTo method for it to be able to do that?


It's called like so:

Issue (int vol, int num)


so sort the ArrayList<Issue> issues by volume and number using Collections.sort(issues). Im just stuck on how to implement the compareTo method for both the volume AND number.





Explanation / Answer


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote