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 equalsObject 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 if A comes before B in order, ie ABA
returns A and are equivalent,
returns integer A comes after order,
Create a class,
PokemonComparator, that implements Comparator compares two Pok reverse order number. For example, Pokemon number and number compareTo would return a number because should come first. Hint: what you subtracted the numbers?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
