-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFP02CourseExcerise.java
35 lines (22 loc) · 1.22 KB
/
FP02CourseExcerise.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
package com.ysingh.functional;
import java.util.Arrays;
import java.util.List;
public class FP02CourseExcerise {
public static void main(String args[]) {
List<String> courses = Arrays.asList("Spring", "Spring Boot", "API", "Microservices", "AWS", "PCF", "Azure", "Docker", "Kubernetes");
System.out.println("Print all courses:");
courses.stream().forEach(System.out::println);
System.out.println();
System.out.println("Print Courses having Spring in it:");
courses.stream().filter(course -> course.contains("Spring")).forEach(System.out::println);
System.out.println();
System.out.println("Print Courses having name with atleast 4 letters:");
courses.stream().filter(course -> course.length() > 3).forEach(System.out::println);
System.out.println();
System.out.println("Print Number of Characters for each course:");
courses.stream().map(course -> course.length()).forEach(System.out::println);
System.out.println();
System.out.println("Find first course have length greater than 11 and print it in upper case:");
System.out.println(courses.stream().peek(System.out::println).filter(course -> course.length() > 11).map(String::toUpperCase).peek(System.out::println).findFirst());
}
}