1
1
package org .rohit ;
2
2
3
+ import org .rohit .dto .PersonRepo ;
3
4
import org .rohit .entity .Address ;
4
5
import org .rohit .entity .Person ;
5
6
6
- import java .util .ArrayList ;
7
- import java .util .Comparator ;
8
- import java .util .HashMap ;
9
- import java .util .HashSet ;
10
- import java .util .List ;
11
- import java .util .Map ;
12
- import java .util .Set ;
13
- import java .util .StringJoiner ;
7
+ import java .util .*;
14
8
import java .util .function .Function ;
15
9
16
10
import static java .util .Optional .of ;
17
- import static java .util .stream .Collectors .counting ;
18
- import static java .util .stream .Collectors .filtering ;
19
- import static java .util .stream .Collectors .groupingBy ;
20
- import static java .util .stream .Collectors .joining ;
21
- import static java .util .stream .Collectors .mapping ;
22
- import static java .util .stream .Collectors .toList ;
23
- import static java .util .stream .Collectors .toMap ;
24
- import static java .util .stream .Collectors .toSet ;
11
+ import static java .util .stream .Collectors .*;
25
12
26
13
public class Application {
27
14
28
15
16
+ private static final String ROHIT = "ROHIT" ;
17
+
29
18
public static void main (String [] args ) {
30
19
31
- String idea = "welcome to intellij idea tips session " ;
20
+ List < Person > allPerson = PersonRepo . getPeples () ;
32
21
22
+ getAll (allPerson );
23
+ findByName (allPerson , ROHIT );
33
24
34
- List < Integer > integers = takeWhile ( );
25
+ groupByDP ( allPerson );
35
26
36
- System . out . println ( integers );
27
+ grpByCollectIntoSet ( allPerson );
37
28
29
+ grpByCounting (allPerson );
38
30
39
- }
31
+ grpByMappingCollect (allPerson );
32
+
33
+ grpByFilterCollect (allPerson );
34
+
35
+ grpByMap (allPerson );
36
+
37
+ mapWithDuplicateKeyProtection (allPerson );
38
+
39
+ mapWithoutDuplicateKeyProtection (allPerson );
40
+
41
+
42
+ sortAndCollect (allPerson );
43
+
44
+ anyMatch (allPerson );
45
+
46
+
47
+ findFirstWithDeafultValue (allPerson );
48
+
49
+ stringJoinning (allPerson );
50
+
51
+
52
+ count (allPerson );
53
+
54
+ takeWhile ();
40
55
41
- private static void stringHolder (String name ) {
42
- throw new UnsupportedOperationException ("method not implemented" );
43
- }
44
- private static void stringDemo (String name ) {
45
- throw new UnsupportedOperationException ("method not implemented" );
46
56
}
47
57
48
- private static List < Integer > takeWhile () {
58
+ private static void takeWhile () {
49
59
List <Integer > oneToTen = List .of (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 );
50
60
List <Integer > takeUpto5 = oneToTen .stream ()
51
61
.takeWhile (i -> i != 5 )
52
62
.collect (toList ());
53
- System .out .println (takeUpto5 );
54
63
64
+ System .out .println (takeUpto5 );
55
65
56
66
List <Integer > takeUpto05 = new ArrayList <>();
57
67
for (Integer i : oneToTen ) {
@@ -61,11 +71,9 @@ private static List<Integer> takeWhile() {
61
71
takeUpto05 .add (i );
62
72
}
63
73
64
- return takeUpto05 ;
74
+ System . out . println ( takeUpto05 ) ;
65
75
}
66
76
67
- private static final String ROHIT = "ROHIT" ;
68
-
69
77
private static void grpByMap (List <Person > allPerson ) {
70
78
Map <String , Map <String , Person >> stringMapMap = allPerson .stream ()
71
79
.collect (groupingBy (Person ::getFname ,
0 commit comments