FizzBuzz 问题java
时间: 2023-09-24 14:05:55 浏览: 50
Sure, I can help you with the FizzBuzz problem in Java! FizzBuzz is a classic programming problem that asks you to print the numbers from 1 to 100, but for multiples of 3 print "Fizz" instead of the number, for multiples of 5 print "Buzz" instead of the number, and for multiples of both 3 and 5 print "FizzBuzz".
Here's a Java program that does just that:
```
public class FizzBuzz {
public static void main(String[] args) {
for (int i = 1; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
System.out.println("FizzBuzz");
} else if (i % 3 == 0) {
System.out.println("Fizz");
} else if (i % 5 == 0) {
System.out.println("Buzz");
} else {
System.out.println(i);
}
}
}
}
```
I hope that helps! Let me know if you have any more questions.