Built-in Functional Interfaces¶
Built-in Functional Interfaces are a set of core interfaces provided in the java.util.function package to support Lambda expressions and functional programming in Java. They allow developers to pass actions or methods as parameters, similar to callback functions in JavaScript^[600-developer-java-java8-java8-lambda.md].
Common Interfaces¶
The Java standard library provides several primary functional interfaces to handle different function shapes^[600-developer-java-java8-java8-lambda.md]:
- Consumer\<T>: Represents a unary function from
Ttovoid(an operation that accepts an input argument and returns no result)^[600-developer-java-java8-java8-lambda.md]. - Function\<T, R>: Represents a unary function from
TtoR(a function that accepts one argument and produces a result)^[600-developer-java-java8-java8-lambda.md]. - Predicate\<T>: Represents a unary function from
Ttoboolean(a function that returns a boolean value based on the input)^[600-developer-java-java8-java8-lambda.md]. - Supplier\<T>: Represents a nilary function to
R(a function that supplies a value without taking any input arguments)^[600-developer-java-java8-java8-lambda.md].
Related Concepts¶
- [[Lambda Expressions]]
- [[Java 8 Features]]
Sources¶
^[600-developer-java-java8-java8-lambda.md]