here are 5 ways you can iterate through List.
- For Loop
- Advanced For Loop
- While Loop
- Collections’s stream() util (Java8)
You need JDK 8 to run below program as
point-5 above uses
java.util.stream.Stream.forEach(Consumer<? super String> action) performs an action for each element of this stream.