🌐
Oracle
docs.oracle.com › javase › tutorial › java › javaOO › methodreferences.html
Method References (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
The method references Person::compareByAge and MethodReferencesExamples::appendStrings are references to a static method. The following is an example of a reference to an instance method of a particular object:
🌐
Baeldung
baeldung.com › home › java › core java › method references in java
Method References in Java | Baeldung
March 26, 2025 - Finally, let’s explore how to create a no-operation function that can be referenced from a lambda expression. In this case, we’ll want to use a lambda expression without using its parameters. ... As it is a varargs method, it will work in any lambda expression, no matter the referenced object or number of parameters inferred.
🌐
CodingNomads
codingnomads.com › java-method-reference-examples
Java Method Reference Examples
As you can see, the method reference takes the person object that was created and references it to the instanceMethodReference method. The result of this reference would print the name of each persons. Instance method reference: Susan Instance method reference: Kenny
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-method-references
Java Method References - GeeksforGeeks
December 4, 2025 - Explanation: This example show how to use a constructor method reference to create objects. We have created a Person class and it gives each person a random name. The getObjectList method creates a list of objects by using a supplier, which ...
🌐
Tutorialspoint
tutorialspoint.com › java › java_method_references.htm
Java - Method References
A static method can be referred using "::" symbol easily without creating any instance of the class, and by using the class name. ... In this example, we are referencing the static method of our class to print the elements in three ways.
🌐
danvega.dev
danvega.dev › blog › java-method-references
Java Method References - A Beginner's Guide
August 1, 2024 - It's saying "use the println method of System.out for each element". Nice and clean, right? This type is used when you want to refer to a method of a specific object instance.
🌐
HowToDoInJava
howtodoinjava.com › home › java 8 › java 8 method reference (with examples)
Java 8 Method Reference (with Examples)
May 29, 2024 - This method reference is used when we want to refer to a static method without invoking it. An example to use Math.max() which is a static method.
🌐
Scaler
scaler.com › home › topics › method reference in java 8
Method Reference in Java 8 - Scaler Topics
April 28, 2024 - The above lambda expression can get replaced by a method reference. The shorted code looks like this: object::instanceMethod ... In the above example, we have defined a functional interface named display.
Find elsewhere
🌐
Medium
medium.com › javarevisited › method-references-in-java8-9714496d5306
Method References in Java8. Method references provide a shorthand… | by Srikanth Dannarapu | Javarevisited | Medium
April 20, 2023 - In this example, we created a reference to the getName method of the Person class instance person using the person::getName syntax. We then assigned this reference to a Supplier variable, which is a functional interface that takes no arguments ...
🌐
BeginnersBook
beginnersbook.com › 2017 › 10 › method-references-in-java-8
Method References in Java 8
import java.util.Arrays; public class Example { public static void main(String[] args) { String[] stringArray = { "Steve", "Rick", "Aditya", "Negan", "Lucy", "Sansa", "Jon"}; /* Method reference to an instance method of an arbitrary * object of a particular type */ Arrays.sort(stringArray, ...
🌐
Medium
medium.com › @mehmed6 › method-reference-in-java-making-your-code-cleaner-95b98a74e783
Method Reference in Java: Making Your Code Cleaner | by Mehmet Dogan | Medium
October 7, 2023 - Specify the name of the method and (if necessary) the class name within the Method Reference. Below are examples demonstrating how to use different types of Method Reference:
Top answer
1 of 1
10

Good place you to start understanding the method reference is the Oracle Documentation, that says:

You use lambda expressions to create anonymous methods. Sometimes, however, a lambda expression does nothing but call an existing method. In those cases, it's often clearer to refer to the existing method by name. Method references enable you to do this; they are compact, easy-to-read lambda expressions for methods that already have a name.

Think of it this way:

"Method definition (particular body, signature and a return type) exists; why shall I create a new lambda expression if I can reuse existing code? let's refer to the already defined method and reuse it."


Four kinds of method references:

  1. SomeType::staticMethodName - reference to the static method (you just refer to the static method of "SomeType" class);

  2. someTypeInstance::instanceMethodName - reference to the instance method of a particular object (here, you need an actual object, from which you obtain the method reference);

  3. SomeType::instanceMethod - reference to the instance method of an arbitrary object of a particular type (you do not need to explicitly create an object in this case);

  4. SomeType::new - reference to the constructor (you simply refer to the constructor).


Difference between (2) the particular object's method reference and (3) arbitrary object's method reference:

In the first two examples, the method reference is equivalent to a lambda expression that supplies the parameters of the method. For example:

System.out::println == x -> System.out.println(x);
Math::pow == (x, y) -> Math.pow(x, y)

In the third case, the first parameter becomes the target of the method, as in:

String::compareToIgnoreCase == (x, y) -> x.compareToIgnoreCase(y)
🌐
JavaTechOnline
javatechonline.com › home › method reference in java 8 [::]
Method Reference In Java 8 [::] - JavaTechOnline
July 10, 2025 - Typically, we can provide Method references in three ways, sometimes called the types of it. ... Now, let’s try to observe them one by one from below table. ... We will cover them separately in the subsequent sections. Furthermore, in this section we will see the example of each type one by one.
🌐
InfoWorld
infoworld.com › home › blogs › java challengers
How to use method references in Java | InfoWorld
October 24, 2025 - Such method references are used ... code flexibility and reuse. For example, the toUpperCase() method of the String class does not take any parameters and returns a String....
🌐
Java Guides
javaguides.net › 2018 › 07 › java-8-method-references.html
Java 8 Method References
March 30, 2022 - You can refer to a constructor by using the new keyword. Here, we are referring constructor with the help of a functional interface. ... Example 1: The below example demonstrates the usage of method reference to the constructor.
🌐
Upgrad
upgrad.com › home › blog › software development › understanding method reference in java 8: syntax, types, and use cases
Guide to Method Reference in Java 8: Syntax, Types & Uses
June 5, 2025 - Preferred Contexts: Method references ... Consumer, Supplier, or Function. For example, use Consumer to print messages, Function to transform data, and Supplier to provide values, making method references practical and ...
🌐
Hero Vired
herovired.com › learning-hub › topics › method-reference-in-java-8
Method Reference in Java 8: Explained with Code Examples
September 20, 2024 - Method references allow us to use a currently existing method just as an argument to the function. When we have only one abstract method in the interface then it is the functional interface. This type of interface can represent a single task or function. We can see different in-built functional interfaces which are provided by Java 8. For example, functional interfaces like Runnable, Callable, Comparator, and more.
🌐
DEV Community
dev.to › ggorantala › what-are-java-method-references-and-kinds-of-method-references-available-d34
What Are Java Method References And Kinds Of Method References Available? - DEV Community
March 14, 2022 - The above simple explanation is the same for this method reference bookApplication::compareByTitle. The following is an example of a reference to an instance method of an arbitrary object of a particular type.
🌐
InfoWorld
infoworld.com › home › blogs › java 101: learn java
Get started with method references in Java | InfoWorld
November 12, 2019 - A static method reference refers to a static method in a specific class. Its syntax is className::staticMethodName, where className identifies the class and staticMethodName identifies the static method. An example is Integer::bitCount.