beginnerFunctional Programming

What are Method References in Java, and what are the 4 types?

A method reference is shorthand for a lambda that just calls an existing method — written as Class::method. The 4 types are: a static method (String::valueOf), an instance method on a particular object (someList::add), an instance method on an arbitrary object of a type (String::toUpperCase, where the object becomes the first parameter), and a constructor reference (ArrayList::new).

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to How does HashMap work internally? (hashing, buckets, collision)← Back to all Core Java questions