This is my second attempt at FizzBuzz in Java8 with Lambdas.

The first incarnation I did can be found here. It's more enterprisey.

  • This StackOverflow page is where I found out about IntStream.boxed().
  • This thing is kind of a one liner. Reminds me of how in Scala land a lot of things surprisingly end up being a single expression.
  • I wasn't a big fan of the ternary operator before getting into FP. As you strive for more stateless coding you'll find it's your friend.
package com.neidetcher.java8;

import java.util.stream.IntStream;

public class FizzBuzz {
    public static void main(String[] args){
        IntStream.range(1, 100)
                .boxed()
                .map(x -> x+": " + (x%3==0? "Fizz": "") + (x%5==0? "Buzz": ""))
                .forEach(System.out::println);
    }
}