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);
		};
		e.getName("ankit");
		Test e1 = MethodReferenceTest::getInfo;
		e1.getName("ankitky");
	}
}
				
			

Output :-
welcome:- ankit
checking-ankitky

Write a program to use method reference of java 8? Read More »