Create a Main.java file that: Sorts a List of people using Person’s natural ordering. Uses a custom Comparator with an anonymous class that sorts the List of people by name in ascending order. Uses a custom Comparator with a lambda implementation that sorts the list of people by name in descending order.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter12: Exception Handling
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
  1. Create a Person class that has the properties: name and age.
  2. Override toString so that it displays a Person object like this:

Where name is the value of the name property and age is the value of the age property.

"<Name: name, Age: age>"

Person class should have a natural ordering by age in descending order. 

Create a Main.java file that:

    1. Sorts a List of people using Person’s natural ordering.
    2. Uses a custom Comparator with an anonymous class that sorts the List of people by name in ascending order. 
    3. Uses a custom Comparator with a lambda implementation that sorts the list of people by name in descending order.
Expert Solution
steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,