java.util.Comparator Implementation
Hi all ,
Can you please help me understand the following question.I have been attending the interviews .I have been asked this in one of the interview.Thanks in advance.
Assume the following code snippet exists inside a java.util.Comparator implementation.
Fill in the method.
/**
* Compares o1 and o2.
* @return -1 if o1's first name, middle name are lexically less
* than o2's first name, middle name, 0 if o1's first name
* and middle name are lexically the same as o2's,
* and 1 otherwise.
*/
public int compare(Object o1, Object o2) {
// Write your code here.
}
Override the following methods for an implementation of Person:
•
int java.lang.Object.hashCode()
boolean java.lang.Object.equals(Object o)