-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
24 lines (19 loc) · 823 Bytes
/
Copy pathMain.java
File metadata and controls
24 lines (19 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import examples.Employee;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
List<Employee> employeeList=new ArrayList<>();
employeeList.add(new Employee("jane",5000));
employeeList.add(new Employee("nathan",6000));
employeeList.add(new Employee("akshay",9000));
employeeList.add(new Employee("akshay",4000));
//sort the list in descending order of names followed by increasing salaries
var employeeComparator=Comparator.comparing((Employee emp)->emp.getName()).reversed()
.thenComparing(emp->emp.getSalary());
employeeList.sort(employeeComparator);
System.out.println(employeeList);
}
}