Created
June 7, 2009 10:08
-
-
Save koduki/125259 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ifによる記述 | |
String x; | |
if(n % 15 == 0){ | |
x = "FizzBuzz"; | |
}else if(n % 5 == 0){ | |
x = "Fizz"; | |
}else if(n % 3 == 0){ | |
x = "Buzz"; | |
}else{ | |
x = x.toString(); | |
} | |
// 3項演算子による記述 | |
String x = (n % 15 == 0) ? "FizzBuzz" | |
:(n % 5 == 0) ? "Fizz" | |
:(n % 3 == 0) ? "Buzz" | |
: x.toString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment