-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFP11MethodReferences.java
More file actions
29 lines (20 loc) · 926 Bytes
/
FP11MethodReferences.java
File metadata and controls
29 lines (20 loc) · 926 Bytes
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
package com.ysingh.functional;
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
public class FP11MethodReferences {
public static void main(String[] args) {
List<String> courses = Arrays.asList("Spring", "Spring Boot", "API", "Microservices", "AWS", "PCF", "Azure", "Docker", "Kubernetes");
//Method Reference on Static Method
courses.stream().map(str -> str.toUpperCase()).forEach(System.out::println);
System.out.println("---------------");
//Method Reference on Object of the class
courses.stream().map(String::toUpperCase).forEach(System.out::println);
System.out.println("---------------");
Supplier<String> supplier = () -> new String();
System.out.println("Empty String 1: "+supplier.get());
//Method Reference on Constructor of the class
Supplier<String> supplier1 = String::new;
System.out.println("Empty String 2: "+supplier1.get());
}
}