Menu Bar

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Thursday, 19 January 2017

What is Method References In Java ?


Method References :

Method References help us to point to methods by their names,A method references is described using ::(double colon) symbol.

It is used to point the following types of method : 
  1. static methods
  2. instance methods 
  3. constructor with new operator
Example Showing Method References:

import java.util.ArrayList;
import java.util.List;

public class MethodReferenceExample {

public static void main(String[] args) {

List<String> list = new ArrayList<String>();
list.add("D");
list.add("A");
list.add("C");
list.add("B");
list.forEach(System.out::println);
}

}
Program Output :

D
A
C
B



      
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.



Share this Blog with yours Friends !!

No comments:

Post a Comment