Square CSS

Monday, May 25, 2020

Predicate : Functional Interface Java 8

Introduction


In this tutorial we will look at the use of Predicate a functional interface introduced in java 8.

Refer The video Tutorial for detail




Use Case 


Predicate is a functional interface which is used for returning boolean value based on some data.The sample code is shown below.



    //return boolean value Predicate<String> pred=new Predicate<String>() { @Override public boolean test(String str) { return str.length()>10; } }


The above case will return true if the string passed to the method will have length grater than 10.

Conclusion 


In this tutorial we saw the use case of functional interface - Predicate. which is introduced in java 8 to get the boolean result.

No comments:

Post a Comment

Some Algorithms

Algorithm: Tower of Hanoi

Tower of Hanoi consists of three towers called as pegs with n number of rings. Rings are of different size.  Conditions to be fulfill...

Popular Posts