Java examples for Lambda Stream:Stream
Create Stream from Array and do forEach action
import java.util.stream.Stream; 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(); }/*w w w.j ava 2 s . co m*/ public void printAllNotes() { Stream.of(BLOG_ENTRIES).forEach(note -> System.out.println(addNote(note))); } public String addNote(String note) { return note.contains("Note") ? note : note + " Note"; } }