Question: X 1 0 4 1 : Complete compareTo ( ) 2 The Person class below implements the Comparable interface. You must complete the compareTo method.
X: Complete compareTo
The Person class below implements the Comparable interface. You must complete the compareTo method.
public class Person implements Comparable
public Person String f String l
public int compareToPerson o
public String getFirst
public String getLast
@Override
public String toString return getLastgetFirst;
public int compareToPerson other
to be completed
Complete the compareTo method in the class above as described below. The method takes as a parameter another Person, named other.
If other is null, return
If the last name in this object is less than the last name in other, return
If the last name in this object is greater than the last name in other, return
If the last name in this object is equal to the last name in other, then:
if first name in this object is less than the first name in other, return
if first name in this object is equal to the first name in other, return
if first name in this object is greater than the first name in other, return
Your Answer:
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
