Question: Question 18 (4 points) Listen Given the class Person below, create a new class called Person Comparator that implements the Comparator interface for objects of

 Question 18 (4 points) Listen Given the class Person below, create

Question 18 (4 points) Listen Given the class Person below, create a new class called Person Comparator that implements the Comparator interface for objects of the class Person such that when the main method is called and myArray array is sorted, the computer output the array in descending order (see below). class Person public String name; public String lastName; public Person(String nane, String lastlane) { this.name = name; this. lastlame - lastName: public String getName(){ return false; 3 public String getLastlanet return lastName: > public static void main(String arg[1] Person myArray[3] - new Person[315 myArray[O] - New Person (Robert". USA") myArray[1] - new Person ("Andy. "UK)) wyArray[2) - new Person("Harish", India) Arrays.cort (ayArray, new Personcomparator) for(Person person wArray) System.out.printin("My name is person.getTime()); Output is My name is Robert My name is Marish My name is Andy Paragraph

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!