Question: In this chapters FlightTimes class, modify the displayFlightTimesTable method by converting the two for loops that iterate over the columns, so that they use for-each

In this chapter’s FlightTimes class, modify the displayFlightTimesTable method by converting the two for loops that iterate over the columns, so that they use for-each loops instead.

There’s no comparable benefit to converting the for loop that iterates over the rows. Why? Because if it’s converted to a for-each loop, then there’s no row index variable, and that variable is needed later on as an index into the cities array:

System.out.printf(CITY_FMT_STR, cities[row]);

Step by Step Solution

3.51 Rating (148 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

If you need the row index variable later in your code you should keep the for loop iterating over th... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming With Java A Problem Solving Approach Questions!