Skip to content

Commit 78d8b48

Browse files
committed
Added Supplier Example
1 parent 3f33387 commit 78d8b48

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.learn.functionalInterfaces;
2+
3+
import com.learn.data.Student;
4+
import com.learn.data.StudentDataBase;
5+
6+
import java.util.List;
7+
import java.util.function.Supplier;
8+
9+
public class SupplierExample {
10+
11+
public static void main(String[] args) {
12+
13+
Supplier<Student> supplier = () -> {
14+
return StudentDataBase.getAllStudents().get(0);
15+
};
16+
17+
System.out.println(supplier.get());
18+
19+
Supplier<List<Student>> supplier1 = StudentDataBase::getAllStudents;
20+
System.out.println(supplier1.get());
21+
}
22+
}

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,38 @@ This repository contains the basic &amp; advance level examples related to Java
1515
* [BiFunction](Modern-Java-Examples/src/com/learn/functionalInterfaces/BiFunctionExample.java)
1616
* [UnaryOperator](Modern-Java-Examples/src/com/learn/functionalInterfaces/UnaryOperatorExample.java)
1717
* [BinaryOperator](Modern-Java-Examples/src/com/learn/functionalInterfaces/BinaryOperatorExample.java)
18+
* [Supplier](Modern-Java-Examples/src/com/learn/functionalInterfaces/SupplierExample.java)
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
1850

1951

2052

0 commit comments

Comments
 (0)