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();
}
```
You might also like to view...
_____ is the science of designing machines, products, and systems to maximize the safety, comfort, and efficiency of the people who use them.
Fill in the blank(s) with the appropriate word(s).
Checking the CPU usage figure will help you know how hard your processor is working.
Answer the following statement true (T) or false (F)
?A(n) ________________ states who has the legal right to initiate an investigation, who can take possession of evidence, and who can have access to evidence.
Fill in the blank(s) with the appropriate word(s).
Which operator can you use with objects of a class without using operator overloading?
What will be an ideal response?