LoginSignup
2
2

More than 1 year has passed since last update.

StreamでFizzBuzz~春は出会いと別れとFizzBuzzの季節~

Last updated at Posted at 2019-03-16

Streamと三項演算子でFizzBuzzクソコード書いてみた。
新卒社員、転職活動で何かと書かされる時期なので備忘録

import java.util.stream.IntStream;

public class FizzBuzz {
    public static void main(String args[]) {
        IntStream.rangeClosed(1, 100).mapToObj(i -> {
            if(i % 15 == 0) return "FizzBuzz";
            if(i % 3 == 0) return "Fizz";
            if(i % 5 == 0) return "Buzz";
            return String.valueOf(i);
        })
        .forEach(System.out::println);
    }
}

2
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2