Question: public class Employee implements Comparable ] private String firstName; private String lastName; private String title; private String ID; private String level; public String getFirstName() {

 public class Employee implements Comparable] private String firstName; private String lastName;

private String title; private String ID; private String level; public String getFirstName(){ return firstName; } public String getLastName() { return lastName; } public

public class Employee implements Comparable] private String firstName; private String lastName; private String title; private String ID; private String level; public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public String getTitle() { return title; } public String getID() { return ID; } public String getLevel() { return level; } public Employee(String firstName, String lastName, String title, String iD, String level) { super(); this.firstName = firstName; this.lastName = lastName; this.title = title; ID = id; this.level = level; } @Override public String toString() { return String.format("%-155 %-155 %-40s %55 %5s ", firstName , lastName, title, level, ID); } @Override public int compareTo (Employee 0) { return this.ID.compareTo(0.ID); } 9 public class Main { 10 110 public static void main(String[] args) { 12 13 ArrayList sorted = loadEmployee ("NameList.csv"); 14 15 // created a shuffled version 16 ArrayList unsorted = new ArrayList(sorted); 17 Collections.shuffle(unsorted); 18 //######### Take Action Below ######### 19 // Add codes to sort the ArrayList and try them out 20 // 1. Create and use an anonymous class that sorts by first name high to low 21 // 2. Create and use a lambda expression that sorts by last name low to high 22 // 3. Create and use a lambda expression that sorts by title 23 // 4. Create and use a lambda expression that sorts first by title then by Level 24 // 5. Create and use a lambda expression that sorts first by last name then by first name 25 26 Collections.sort(unsorted); 27 28 //######### Take Action Below ######### 29 // Use Lambda expression to print all elements of unsorted ArrayList BO } 31 320 public static ArrayList loadEmployee(String filename) { 33 34 BufferedReader br = null; 35 FileReader fr = null; 36 37 ArrayList employees = new ArrayList(); 38 ArrayList lines = new ArrayList(); 39 try { 40 11 fr = new FileReader(filename); 42 br = new BufferedReader(fr); 13 String line; 14 br = new BufferedReader(new FileReader(filename)); 15 46 while ((line = br.readLine()) != null) { 17 lines.add(line); 18 } 19 } catch (IOException e) { 51 I Writable Smart Inse e.printStackTrace(); } finally { try { if (br != null) br.close(); if (fr != null) fr.close(); } catch (IOException ex) { 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 32 } } int count = 0; for (int i = 0; i

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!