0% found this document useful (0 votes)
2 views2 pages

Method Reference

Method references are a feature of Java 8 that allow using methods without directly calling them, serving as a shortcut to lambda expressions. There are three types of method references: to static methods, to non-static methods, and to constructors, each with its own syntax. This feature also facilitates achieving multiple inheritance through interfaces.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Method Reference

Method references are a feature of Java 8 that allow using methods without directly calling them, serving as a shortcut to lambda expressions. There are three types of method references: to static methods, to non-static methods, and to constructors, each with its own syntax. This feature also facilitates achieving multiple inheritance through interfaces.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Method reference

It is a feature of java 8

Method reference means using a method without calling it directly

It is used with functional interfaces and works like a shortcut to lambda expression

Instead of using lambda expression we can use method refrences

Tyoes of Method references

We are having 3 tyoes

Reference to static maethod

References to non static method

Reference to constructor

Reference to Static method

Syntax

Class name :: static MethodName

Reference to an Instance or non-Static Method


Syntax
Class name :: non static MethodName

References to a Constructor

Syntax
Class:: new

Acheiveing multiple inheritance using Interface

You might also like