A reference like String::length or String::startsWith has no receiver of its own, so the functional interface's first parameter supplies the object the method is called on.
BiFunction<String, String, Boolean> startsWith = String::startsWith;
System.out.println(startsWith.apply("hello world", "hello"));
Function<String, Integer> len = String::length;
System.out.println(len.apply("abcdef"));
true
6
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-09-27