Suppose you are implementing the comparable interface in a class representing a Person, where the ordering is based on the age of the person. Write a compareTo method for this class. You may assume that there is an instance variable called age and an accessor method called getAge.
What will be an ideal response?
```
public int compareTo(Object o) {
Person p = (Person) o;
return this.getAge() - p.getAge();
}
```
Computer Science & Information Technology
You might also like to view...
What Windows log stores events collected from other systems, to which the system has a subscription?
A. System B. Remotes C. Forwarded Events D. Servers
Computer Science & Information Technology
The operators !, &&, and || are called relational operators.
Answer the following statement true (T) or false (F)
Computer Science & Information Technology