Pass method to Stream forEach action via method reference - Java Lambda Stream

Java examples for Lambda Stream:Method Reference

Description

Pass method to Stream forEach action via method reference

Demo Code



import java.util.stream.Stream;

/**/*from   w  w w.  j a v a2  s . co  m*/
 * Starting point of the application
 */
public class BlogMain {

  private final String[] BLOG_ENTRIES = {"First Note", "Another Note", "End"};

  public static void main(String[] args) {
    System.out.println("Blog up and running");
    new BlogMain().printAllNotes();
  }

  public void printAllNotes(){
    Stream.of(BLOG_ENTRIES).forEach(System.out::println);
  }

}

Related Tutorials