- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use BooleanSupplier in lambda expression in Java?
BooleanSupplier is a functional interface defined in the "java.util.function" package. This interface can be used as an assignment target for a lambda expression or method reference. BooleanSupplier interface has only one method getAsBoolean() and returns a boolean result, true or false.
Syntax
@FunctionalInterface public interface BooleanSupplier { boolean getBoolean(); }
Example
import java.util.function.BooleanSupplier; public class BooleanSupplierLambdaTest { public static void main(String[] args) { BooleanSupplier Obj1 = () -> true; BooleanSupplier Obj2 = () -> 5 < 50; // lambda expression BooleanSupplier Obj3 = () -> "tutorialspoint.com".equals("tutorix.com"); System.out.println("Result of Obj1: " + Obj1.getAsBoolean()); System.out.println("Result of Obj2: " + Obj2.getAsBoolean()); System.out.println("Result of Obj3: " + Obj3.getAsBoolean()); } }
Output
Result of Obj1: true Result of Obj2: true Result of Obj3: false
- Related Articles
- How to use IntSupplier in lambda expression in Java?
- How to use Supplier interface in lambda expression in Java?
- How to use BinaryOperator interface in lambda expression in Java?
- How to use UnaryOperator interface in lambda expression in Java?
- How to use a return statement in lambda expression in Java?
- How to use an ArrayList in lambda expression in Java?\n
- How to use Predicate and BiPredicate in lambda expression in Java?
- How to use FileFilter interface in lambda expression in Java?\n
- How to use Consumer and BiConsumer interfaces in lambda expression in Java?
- How to use Function and BiFunction interfaces in lambda expression in Java?
- How to use this and super keywords with lambda expression in Java?
- How to write a conditional expression in lambda expression in Java?
- How to use a final or effectively final variable in lambda expression in Java?
- Lambda expression in Java 8
- How to implement IntBinaryOperator using lambda expression in Java?

Advertisements