Define a Person class which has name and age. Also define an ageComparator class which implements Comparator interface to compare the age of people. Please create 5 instances from Person class and put them into a LinkedList at any order. Sort them by their ages in ascending order, and print them. You can put the pseudo code here (or you can write in Java code and submit the Java file with its output).
Java Built-in Comparator interface, Java Built-in Collections class : A simple case of how to sort LinkedList using Comparator. Please use Java Built-in LinkedList class. (https://docs.oracle.com/javase/8/docs/api/allclasses-noframe.html
Please make a summary for Java built-in Comparator interface & Collections class (especially sort(list, c) methods in Collections class).
Define a Person class which has name and age. Also define an ageComparator class which implements Comparator interface to compare the age of people.
Please create 5 instances from Person class and put them into a LinkedList at any order.
Sort them by their ages in ascending order, and print them.
You can put the pseudo code here (or you can write in Java code and submit the Java file with its output).
)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images