Java 8 Consumer and Supplier Example

1 min read
Date: 2018-01-11
This Java 8 tutorial explains the Consumer<T>
and Supplier<T>
functional interfaces. Consumer<T>
takes an object as input and performs an operation without returning a value (e.g., printing). Supplier<T>
takes no input but returns an object of type T. Both are used to avoid defining new functional interfaces. The tutorial provides code examples demonstrating their usage in a Java project created using Eclipse and Maven, showcasing the accept()
method for Consumer
and the get()
method for Supplier
.
Read more: https://examples.javacodegeeks.com/core-java/java-8-consumer-supplier-example/
0
Subscribe to my newsletter
Read articles from Yatin B. directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
