File tree Expand file tree Collapse file tree
modules/src/main/java/com/platzi/functional/_13_streams Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .platzi .functional ._13_streams ;
2+
3+ import com .platzi .functional ._06_reference_operator .NombresUtils ;
4+
5+ import java .util .List ;
6+ import java .util .Optional ;
7+ import java .util .stream .IntStream ;
8+ import java .util .stream .Stream ;
9+
10+ public class Streams {
11+ public static void main (String [] args ) {
12+ List <String > courseList = NombresUtils .getList (
13+ "Java" ,
14+ "FrontEnd" ,
15+ "Backend" ,
16+ "FullStack" );
17+ for (String course : courseList ) {
18+ String newCourseName = course .toLowerCase ().replace ("!" , "!!" );
19+ System .out .println ("Platzi: " + newCourseName );
20+ }
21+
22+ Stream <String > coursesStream = Stream .of ("Java" ,
23+ "FrontEnd" ,
24+ "Backend" ,
25+ "FullStack" );
26+
27+ // Stream<Integer> courseLengthStream = coursesStream.map(course -> course.length());
28+
29+ // Optional<Integer> longest = courseLengthStream.max((x, y) -> y - x);
30+
31+ Stream <String > emphasisCourses = coursesStream .map (course -> course + "!" );
32+ Stream <String > justJavaCourses = emphasisCourses .filter (course -> course .contains ("Java" ));
33+ justJavaCourses .forEach (System .out ::println );
34+
35+ Stream <String > coursesStream2 = courseList .stream ();
36+
37+ addOperator (
38+ coursesStream2 .map (course -> course + "!!" )
39+ .filter (course -> course .contains ("Java" ))
40+ ).forEach (System .out ::println );
41+ }
42+
43+ static <T > Stream <T > addOperator (Stream <T > stream ){
44+ return stream .peek (data -> System .out .println ("Dato: " + data ));
45+ }
46+ }
Original file line number Diff line number Diff line change 1+ package com .platzi .functional ._13_streams ;
2+
3+ import java .util .stream .IntStream ;
4+
5+ public class TypeStream {
6+ public static void main (String [] args ) {
7+ IntStream infiniteStream = IntStream .iterate (0 , x -> x + 1 );
8+ infiniteStream .limit (1000 )
9+ .parallel ()
10+ .filter (x -> x % 2 == 0 )
11+ .forEach (System .out ::println );
12+ }
13+ }
You can’t perform that action at this time.
0 commit comments