Question: While the equals ( Object ) method can tell us if two objects are equal or not, it does not tell us which one should

While the equals(Object) method can tell us if two objects are equal or not, it does not tell us which one should come first in order. The Comparator interface can be used for that. It is a generic interface that can be implemented to compare two objects of its generic type: let's call them A and B.
a. It returns an integer 0 if A comes before B in order, i.e. ABA==B>B>0BA
b.It returns 0if A and B are equivalent, i.e.A==B
c.It returns an integer >0if A comes after Bin order, i.e.A>B
Create a class,
PokemonComparator, that implements Comparator compares two Pokmonin reverse order by number. For example, if Pokemon A's number is25 and B's number is50,A. compareTo(B) would return a number >0 because B should come first. Hint: what if you subtracted the numbers?
While the equals ( Object ) method can tell us if

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!