Lambda: An unbound instance method reference takes the receiver as its first parameter

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.

Code
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"));
Output
true
6
Advertisement
More in JAVA

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

© Java Coding Hub · About · Contact · Privacy · Terms