0
/ 2.0
The Person class below implements the Comparable
interface. You must complete the compareTo
method.
public class Person implements...
The Person class below implements the Comparable
interface.
You must complete the compareTo
method.
public class Person implements Comparable<Person> {
// ...
public Person (String f, String l) { ... }
public String getFirst() { ... }
public String getLast() { ... }
@Override
public String toString() { return getLast()+", "+getFirst(); }
public int compareTo(Person 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
.
other
is null, return -1.other
, return -1.other
, return 1.other
, then:
other
, return -1.other
, return 0.other
, return 1.Your feedback will appear here when you check your answer.