Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What are some of the other ways that I can print the ArrayList fizzBuzzList out? import java.util.*; public class Main { List fizzBuzzList = new

What are some of the other ways that I can print the ArrayList fizzBuzzList out?

import java.util.*;

public class Main {

List fizzBuzzList = new ArrayList(100);

public void fizzBuzzIterator(){

for (int i = 1; i <= 100; i++) { //fizzBuzzList.add("0");

if (((i % 3) == 0) && ((i % 5) == 0)) {

fizzBuzzList.add(i-1, "FizzBuzz");

}

else if ((i % 3) == 0){

fizzBuzzList.add(i-1, "Fizz");

}

else if ((i % 5) == 0) {

fizzBuzzList.add(i-1, "Buzz");

}

else {

fizzBuzzList.add(i-1, String.valueOf(i));

}

}

}

public static void main(String[] args){ Main m = new Main(); m.fizzBuzzIterator(); for(int k = 0; k < m.fizzBuzzList.size(); k++){

System.out.println(m.fizzBuzzList.get(k));

}

}

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting Information System

Authors: James A. Hall

7th Edition

978-1439078570, 1439078572

Students also viewed these Databases questions

Question

Why did you choose your school?

Answered: 1 week ago