File tree Expand file tree Collapse file tree 4 files changed +7
-4
lines changed
main/java/com/baeldung/stream Expand file tree Collapse file tree 4 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 1- package com .baeldung .streamApi ;
1+ package com .baeldung .stream ;
22
33import java .util .List ;
44import java .util .stream .Stream ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public static Integer getInfiniteStreamLastElementUsingReduce() {
1616 }
1717
1818 public static String getLastElementUsingSkip (List <String > valueList ) {
19- long count = valueList . stream (). count ();
19+ long count = ( long ) valueList . size ();
2020 Stream <String > stream = valueList .stream ();
2121 return stream .skip (count - 1 ).findFirst ().orElse (null );
2222 }
Original file line number Diff line number Diff line change 11package com .baeldung .java8 ;
22
3- import com .baeldung .streamApi .Product ;
3+ import com .baeldung .stream .Product ;
44import org .junit .Before ;
55import org .junit .Test ;
66import org .slf4j .Logger ;
Original file line number Diff line number Diff line change 66import java .util .List ;
77import java .util .stream .Collectors ;
88import java .util .stream .IntStream ;
9+ import java .util .stream .Stream ;
910
1011import static org .junit .Assert .assertEquals ;
1112import static org .junit .Assert .assertTrue ;
@@ -65,7 +66,9 @@ public void givenARangeWhenForEachIsCalledThenTheIndicesWillBePrinted() {
6566 @ Test
6667 public void givenAnArrayWhenSumIsCalledThenTheCorrectSumIsReturned () {
6768
68- int sum = Arrays .asList (33 ,45 ).stream ().mapToInt (a -> a ).sum ();
69+ int sum = Stream .of (33 ,45 )
70+ .mapToInt (i -> i )
71+ .sum ();
6972
7073 assertEquals (78 , sum );
7174 }
You can’t perform that action at this time.
0 commit comments