Method References in Java — Four Types Explained
Fast recall
Quick revision
Core answer
Whether you know all four types and can distinguish between bound and unbound instance method references
Confusing bound vs unbound instance references — String::length is unbound (takes a String parameter), while str::length is bound (captures the specific str instance)
Explain when method references compile to the same bytecode as lambdas, show examples of all four types in stream pipelines, and note that method references improve readability but have the same performance as lambdas
Interview-ready guide
Interview answer
Method references are lambdas that delegate to an existing method without adding logic — String::toUpperCase is equivalent to s -> s.toUpperCase(), same bytecode, but communicates intent faster.
Four types:
- Static:
Integer::parseInt— element becomes the argument to the static method - Bound instance:
System.out::println— captures a specific object; element becomes the argument - Unbound instance:
String::length— stream element becomes the instance (equivalent tos -> s.length()) - Constructor:
ArrayList::new— creates new instances (equivalent to() -> new ArrayList<>())
Bound vs unbound (the interview catch):
str::toUpperCase(lowercase variable) — calls on that specific captured stringString::toUpperCase(class name) — expects the stream to provide the instance- Same
ClassName::methodsyntax, completely different semantics
I recommend method references when the lambda is pure delegation — use an explicit lambda when you need to transform, combine, or reorder arguments. No performance difference; the choice is purely readability.
Method References in Java — Four Types Explained
Direct Answer
A method reference is a shorthand for a lambda that simply calls an existing method. Instead of writing x -> x.toUpperCase(), you write String::toUpperCase. There are four types: static reference (Class::staticMethod), bound instance (instance::method), unbound instance (Class::instanceMethod), and constructor reference (Class::new).
Common Mistakes & Pitfalls
Confusing bound vs unbound instance references — String::length is unbound (takes a String parameter), while str::length is bound (captures the specific str instance)
Check your understanding
Answer these without looking back at the article.
- When would you prefer a lambda over a method reference?
- Can you use method references with overloaded methods?
- How does the compiler resolve which functional interface a method reference matches?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.