Write a program to use method reference of java 8?

Method reference is a functional interface.it is use to replace lambda expression to call a method.Method reference to call a static method of a class – Class::staticMethod

					interface Test {
	public void getName(String name);

public class MethodReferenceTest {
	public static void getInfo(String info) {
		System.out.println("checking- " + info);
	public static void main(String[] args) {
		Test e = (String name) -> {
			System.out.println("welcome:- " + name);
		Test e1 = MethodReferenceTest::getInfo;

Output :-
welcome:- ankit

Leave a Comment

Your email address will not be published. Required fields are marked *