I've become able to write a little code, so I wrote FizzBuzz for the time being.
FizzBuzz.java
public class FizzBuzz{
public static void main(String[] args){
for(int i = 1; i < 101; i ++){
String display;//Variables to display
if(i % 3 == 0 && i % 5 == 0){
display = "FizzBuzz";
}else if(i % 3 == 0){
display = "Fizz";
}else if(i % 5 == 0){
display = "Buzz";
}else{
//Convert int type variable "i" to String type
display = String.valueOf(i);
}
System.out.println(display);//display
}
}
}
Recommended Posts