Writing forEach with java 8 lambda
Let’s take a simple example. It’s easier, probably, and can not be – create a list of numbers and display it on the screen through the simplest cycle:
1 2 3 4 5 |
List <Integer> numbers = Arrays.asList (1, 2, 3, 4, 5, 6); for (int number: numbers) { System.out.println (number); } |