55import java .util .OptionalDouble ;
66import java .util .OptionalInt ;
77import java .util .OptionalLong ;
8+ import java .util .stream .Collectors ;
89import java .util .stream .IntStream ;
910import java .util .stream .LongStream ;
1011
@@ -22,6 +23,37 @@ public static void main(String args[]) {
2223 basic5 ();
2324 System .out .println ("*****Basic6****" );
2425 basic6 ();
26+ System .out .println ("*****Basic7****" );
27+ basic7 ();
28+ System .out .println ("*****Basic8****" );
29+ basic8 ();
30+ System .out .println ("*****Basic9****" );
31+ basic9 ();
32+ System .out .println ("*****Basic10****" );
33+ basic10 ();
34+ }
35+
36+ public static void basic10 () {
37+ Double sumValue = IntStream .rangeClosed (1 , 10 ).mapToDouble (Double ::new ).sum ();
38+ System .out .println ("Double value is : " + sumValue );
39+ }
40+
41+ public static void basic8 () {
42+ List <Integer > values = IntStream .rangeClosed (1 , 10 ).mapToObj (Integer ::new ).collect (Collectors .toList ());
43+ values .forEach (System .out ::println );
44+ }
45+
46+ public static void basic9 () {
47+ Long sumValue = IntStream .rangeClosed (1 , 10 ).mapToLong (Long ::new ).sum ();
48+ System .out .println ("Long value is : " + sumValue );
49+ }
50+
51+ public static void basic7 () {
52+ List <Integer > values = IntStream .rangeClosed (1 , 100 ).boxed ().collect (Collectors .toList ());
53+ values .forEach (System .out ::println );
54+
55+ int sumValue = values .stream ().mapToInt (Integer ::intValue ).sum ();
56+ System .out .println (sumValue );
2557
2658 }
2759
0 commit comments