functional interface
An interface with exactly one abstract method, such as Runnable, Supplier or Predicate, which a lambda or method reference can implement.
In more detail
The standard java.util.function package supplies common shapes: Supplier produces a value, Predicate tests one, Function transforms one and Consumer accepts one. Stream operations, Optional and CompletableFuture all take functional interfaces as parameters.
Related terms
- lambda expression — A short anonymous function written inline and passed to other code, such as a condition for a filter.
- predicate — A function or condition that answers true or false about a value, used to filter, search or check data.
- Supplier — A functional interface whose get method takes no arguments and returns a value, used to produce something on demand.
- Runnable — The functional interface for a task that takes no input and returns no result, used to give a thread work to do.
Taught in
- The Streams API — Modern Java: Virtual Threads & High-Throughput Services
- Handling Nulls With Optional — Modern Java: Virtual Threads & High-Throughput Services
- Concurrency Basics: Threads And Runnable — Modern Java: Virtual Threads & High-Throughput Services
- Interfaces: Default, Static And Private Methods — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Lists, Sets, Maps, Deques And Sequenced Collections — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Exceptions, Arrays And Collections — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Lambdas, Functional Interfaces And Method References — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Modules And Concurrency — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep