Created
May 26, 2014 08:01
-
-
Save gakuzzzz/79109168287e707be6a1 to your computer and use it in GitHub Desktop.
ついかっとなってやった。反省はしていない
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.util.stream.Collectors.toList; | |
import java.util.stream.IntStream; | |
public class FizzBuzz { | |
public String chooseWord(final int i) { | |
if (i % 15 == 0) return "FizzBuzz"; | |
if (i % 3 == 0) return "Fizz"; | |
if (i % 5 == 0) return "Buzz"; | |
return String.valueOf(i); | |
} | |
public List<String> apply(final int start, final int end) { | |
return IntStream.rangeClosed(start, end) | |
.mapToObj(this::chooseWord) | |
.collect(toList()); | |
} | |
public static void main(final String[] args) { | |
new FizzBuzz().apply(1, 100).stream().forEach(System.out::println) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment