Skip to content

Commit 59c8b08

Browse files
committed
added Predicate sample code
1 parent 5857d72 commit 59c8b08

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package java8.functionalInterface;
2+
3+
import java.util.function.Predicate;
4+
5+
/**
6+
*
7+
* @author saurav
8+
*
9+
*/
10+
public class PredicateInterfaceDemo1
11+
{
12+
public static Boolean checkSpeed(int speed)
13+
{
14+
if(speed>20)
15+
{
16+
return true;
17+
}
18+
else
19+
{
20+
return false;
21+
}
22+
}
23+
public static void main(String[] args)
24+
{
25+
Predicate<Integer> predicate=PredicateInterfaceDemo1::checkSpeed;
26+
System.out.println(predicate.test(50)); // output : true
27+
}
28+
}

0 commit comments

Comments
 (0)