-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlgorithmsDemo.java
More file actions
32 lines (23 loc) · 784 Bytes
/
Copy pathAlgorithmsDemo.java
File metadata and controls
32 lines (23 loc) · 784 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
25
26
27
28
29
30
31
32
import java.util.*;
public class AlgorithmsDemo {
public static void main(String[] args) {
LinkedList<Integer> ll = new LinkedList<>();
ll.add(-8);
ll.add(20);
ll.add(-20);
ll.add(8);
Comparator<Integer> r = Collections.reverseOrder();
Collections.sort(ll, r);
System.out.print("List sorted in reverse: ");
for (int i : ll)
System.out.print(i + " ");
System.out.println();
Collections.shuffle(ll);
System.out.print("List shuffled: ");
for (int i : ll)
System.out.print(i + " ");
System.out.println();
System.out.println("Minimum: " + Collections.min(ll));
System.out.println("Maximum: " + Collections.max(ll));
}
}