What is the java code for Writing the regular loop that would produce the same output as following?

Assume that you have the following Array declaration and while loop to print out the values in the array:

String cities[] = new String[5];

cities[0] = "Shanghai";

cities[1] = "Honolulu";

cities[2] = "Manila";

cities[3] = "Boston";

cities[4] = "Amsterdam";

int index = 0;

while(index < cities.length)





1 Answer

  • 1 decade ago
    Best Answer

    for(int i =0; i<cities.length; i++){



    think that what you mean :-s

Still have questions? Get your answers by asking now.