Thursday, April 9, 2015

Java 8 without Lambdas to print elements using short hand

Goal
Print all elements in List with Java 8 without Lambdas and a short hand input.

Setup
In following code lets fill in the blanks to print all elements of given list.

@Test
    public void SimpleCollection() {
        List values = Arrays.asList(1, 2, 3, 4, 5, 6);

        values.forEach(/* fill the code here */);

    }

Solution
As the solution is small and trivial the output looks as follows.


@Test
    public void SimpleCollection() {
        List values = Arrays.asList(1, 2, 3, 4, 5, 6);

        values.forEach(System.out::println);

    }

No comments:

Post a Comment