1. Which enhanced for loop can replace the regular for loop in the following code? import java.util.ArrayList;...
Fantastic news! We've Found the answer you've been seeking!
Question:
1. Which enhanced for loop can replace the regular for loop in the following code?
import java.util.ArrayList; public class Restaurant { public static void main(String [] args) { ArrayListmenu = new ArrayList(); menu.add("Grilled Sandwich"); menu.add("Margherita Pizza"); menu.add("Nachos with Salsa"); String dish; for (int i = 0; i < menu.size(); ++i) { dish = menu.get(i); System.out.println(dish); } } }
Group of answer choices
A) for (String item : menu) { System.out.println(menu.item); }
B) for (String item: menu) { System.out.println(item); }
C) for (String item.menu) { System.out.println(item); }
D) for (String menu : item) { System.out.println(menu); }
Related Book For
Posted Date: