In Java 8 features you can use this:
List<String> messages = Arrays.asList("First", "Second", "Third");void forTest(){ messages.forEach(System.out::println);}
Output
FirstSecondThird
In Java 8 features you can use this:
List<String> messages = Arrays.asList("First", "Second", "Third");void forTest(){ messages.forEach(System.out::println);}
FirstSecondThird