Hey all! I honestly bulldozed my way through the FizzBuzz assignment to find something that would work. Now I am in a position where I do not understand why this code works. I understand the ‘if’ and the ‘else if’ statements, however I cannot understand why I pulled “continue” out of my noggin, nor why it works. Could someone take a look, and assist me with cleaning this hot mess up? Thank you for any help you can give! https://www.codecademy.com/courses/learn-java/projects/java-fizzbuzz
Write a FizzBuzz.java program that outputs numbers from 1 to 100… with a catch:
*> *
> * For multiples of 3, printFizz
instead of the number.
> * For the multiples of 5, printBuzz
.
> * For numbers which are multiples of both 3 and 5, printFizzBuzz
.
import java.util.ArrayList;
public class FizzBuzz {
public static void main(String[] args){
// My FizzBuzz attempt
ArrayList<Integer>numbers = new ArrayList<Integer>();
for (int i = 1; i < 100; i++){
if (i % 3 == 0 && i % 5 == 0){
System.out.println("Fizzbuzz");
continue;
}
else if (i % 5 == 0){
System.out.println("Buzz");
continue;
} else if (i % 3 == 0){
System.out.println("Fizz");
continue;
}
System.out.println(i);
}
}
}