-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrayListConcept.java
39 lines (37 loc) · 1.52 KB
/
ArrayListConcept.java
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
33
34
35
36
37
38
39
import java.util.*;
public class ArrayListConcept {
public static void main(String[] args) {
List<String> list = new ArrayList<>(Arrays.asList("Volvo", "Bharat", "Mohit", "Yash"));
list.set(1, "Sonal");
System.out.println(list);
// list.stream().max(Integer::sum).ifPresent(System.out::println);
Collections.sort(list);
System.out.println(list);
//
// list.sort(Comparator.naturalOrder());
// System.out.println(list);
//
// list.sort(Comparator.reverseOrder());
// System.out.println(list);
// list.stream().max(String::compareTo).ifPresent(System.out::println);
// list.sort(Comparator.comparingInt(Integer::intValue).reversed());
// list.stream().max(Integer::compare).ifPresent(System.out::println);
// System.out.println(list);
// list.stream().sorted().forEach(System.out::println);
// list.stream().reduce(Integer::max).ifPresent(System.out::println);
//
// list.sort(Integer::compare);
// System.out.println(list);
// list.stream().sorted().forEach(System.out::println);
// list.sort(Integer::compareTo);
// System.out.println(list);
// list.sort(Collections.reverseOrder());
// System.out.println(list);
// Collections.reverse(list);
// System.out.println(list);
//
// list.stream().reduce(Integer::max).ifPresent(System.out::println);
// list.stream().reduce(Integer::min).ifPresent(System.out::println);
// System.out.println(list);
}
}