Each of the following interfaces is annotated with @FunctionalInterface

Signature

Interface

Method

() → void

Runnable

void run()

() → T

Callable

T call() throws Exception

() → T

Supplier

T get()

() → int

IntSupplier

int getAsInt()

T → void

Consumer

void accept(T t)

int → void

IntConsumer

void accept(int i)

T → R

Function<T,R>

R apply(T t)

T → boolean

Predicate

boolean test(T t)

int → R

IntFunction

R apply(int i)

T → int

ToIntFunction

int applyAsInt(T t)

Method Reference

The operator :: allows referencing an existing method (static or not)

:: on type

  • BinOp add = Integer::sum;
  • ToIntFunction<String> fun = String::length;

:: on instance

  • String hello = “hello”;
  • IntSupplier supplier = hello::length;