Java Method References

Last Updated : 6 Apr 2026

Java method references allow you to refer to methods using functional interfaces in a simple way. They are used instead of lambda expressions when the lambda only calls an existing method.

In this chapter, you will learn about Java Method References, their types (static, instance, and constructor), syntax, and how to use them with functional interfaces through practical examples.

What is Java Method Reference?

A method reference is a shorthand notation used to call a method by referring to it directly using the :: operator. It is a compact alternative to lambda expressions when the lambda simply invokes an existing method.

Types of Method References

There are following types of method references in java:

  1. Reference to a static method.
  2. Reference to an instance method.
  3. Reference to a constructor.
Types of Java Method References

1. Reference to a Static Method

You can refer to static method defined in the class. Following is the syntax and example which describe the process of referring static method in Java.

Syntax

It has the following syntax:

Example 1

In the following example, we have defined a functional interface and referring a static method to it's functional method say().

Output:

Hello, this is static method.

Example 2

In the following example, we are using predefined functional interface Runnable to refer static method.

Output:

Thread is running...

Example 3

You can also use predefined functional interface to refer methods. In the following example, we are using BiFunction interface and using it's apply() method.

Compile and Run

Output:

30

Example 4

You can also override static methods by referring methods. In the following example, we have defined and overloaded three add methods.

Compile and Run

Output:

30
30.0
30.0

2. Reference to an Instance Method

like static methods, you can refer instance methods also. In the following example, we are describing the process of referring the instance method.

Syntax

It has the following syntax:

Example 1

In the following example, we are referring non-static methods. You can refer methods by class object and anonymous object.

Output:

Hello, this is non-static method.
Hello, this is non-static method.

Example 2

In the following example, we are referring instance (non-static) method. Runnable interface contains only one abstract method. So, we can use it as functional interface.

Output:

Hello, this is instance method

Example 3

In the following example, we are using BiFunction interface. It is a predefined interface and contains a functional method apply(). Here, we are referring add method to apply method.

Compile and Run

Output:

30

3. Reference to a Constructor

You can refer a constructor by using the new keyword. Here, we are referring constructor with the help of functional interface.

Syntax

It has the following syntax:

Example

In this example, a constructor reference (Message::new) is used to create an object of the Message class through a functional interface in a concise and readable way.

Compile and Run

Output:

Hello