Java 8 Functional Interface Cheatsheet

A cheatsheet for developing with the Java 8 functional interfaces

O'Reilly has a great in-depth article on the functional interface in Java 8. Here's a quick cheat sheet to keep track of the main types, what they do and common use cases.


A Predicate returns true or false. These are used for filters or replacing big chains of if/else logic.


A Function transforms data. These are used for maps, and other transformations. It is important to not mutate the original data that is passed in.


A Supplier takes no arguments and returns a value of a known type. Fetching, reading or creating resources to be used by other functions are common use cases. Suppliers get things started.


A Consumer accepts a single argument, but does not return any results. Consumers are where mutating functions, things with side-effects, should go. Consumers finish things.

Tags: cheatsheet how-to guide tutorial functional-programming java8

Get great articles about development every month here ⬇️