1 2 3 4 public class test { 5 6 public static void main(String[] args) { 7 one(); 8 } 9 public static void one() { 10 for (int i = 1; i < 101; i++) { 11 if (i%5==0&&i%3==0) { 12 System.out.println("fizzBuss"); 13 }else if(i%3 == 0 || String.valueOf(i).contains("3")){ 14 System.out.println("fizz"); 15 } else if(i%5 == 0 || String.valueOf(i).contains("5")){ 16 System.out.println("Buzz"); 17 } 18 else { 19 System.out.println(i); 20 } 21 22 } 23 } 24 }
输出结果: