Display leap years

The problem

Write a program that displays all the leap years, ten per line, in the twenty-first century (from 2001 to 2100), separated by exactly one space.

Breaking it down

Java 8 time api has a neat way to determine leap years. Using Year.isLeap checks if the year is a leap year, according to the ISO proleptic calendar system rules. Creating a range of years from IntStream we can print the items from the stream.

public static void main(String[] strings) {

    IntStream.rangeClosed(2001, 2100).filter(i -> Year.of(i).isLeap())
            .forEach(System.out::println);
}

Output

2004
2008
2012
2016
2020
2024
2028
2032
2036
2040
2044
2048
2052
2056
2060
2064
2068
2072
2076
2080
2084
2088
2092
2096