-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCaller.java
More file actions
24 lines (21 loc) · 799 Bytes
/
Caller.java
File metadata and controls
24 lines (21 loc) · 799 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
package com.interview.brushups.javacollection.comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Caller {
public static void main(String[] args) {
List<Movie> movies = new ArrayList<>();
Movie movie1 = new Movie(5, 2010, 2, "Die Another Day");
Movie movie2 = new Movie(6, 2002, 5, "Harry Potter");
Movie movie3 = new Movie(2, 2015, 3, "Dracula");
Movie movie4 = new Movie(3, 2006, 5, "Double Dragon");
movies.add(movie1);
movies.add(movie2);
movies.add(movie3);
movies.add(movie4);
System.out.println(movies);
Collections.sort(movies, (m1,m2)-> m2.rating - m1.rating);
//Collections.sort(movies);
System.out.println(movies);
}
}