Question: CompPersons (10) Given the class Person with the following instance variables and standard accessors and mutators (8 points) private int age String name Write a

CompPersons (10)

Given the class Person with the following instance variables and standard accessors and mutators (8 points)

private int age

String name

Write a Comparator CompPersons that implements the Comparator interface for Person for two Persons persA and persB as follows: Compares the two ages and if they are not equal Uses compareTo or an equation that provides the same result) to return the ages from greatest to lowest (i.e. the reverse of the natural order)

else

returns the value using compareTo for the names of persA and persB

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!