Supplier<T>

Description

A factory that’s expected to return either a new instance or a precreated instance

Abstract method

get

default method(s)

Popular usage

To create lazy infinite Streams and as the parameter to the Optional class’s orElseGet method

Primitive specializations

IntSupplier, LongSupplier, DoubleSupplier, …

Get Functional Programming in Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.