Question: How would you write the for loop not assuming that I have Shredded Chess, 25, and 6.95? import java.util.*; public class Main { public static
How would you write the for loop not assuming that I have Shredded Chess, 25, and 6.95?
import java.util.*; public class Main { public static void main(String[] args) { List inventoryItems = new ArrayList(); for(int i=0;i<3;i++){ // add 3 dictionaries Dictionary inventory = new Hashtable(); // create dictionary inventory.put("name","Shredded Cheese"); //add elements in dictionary inventory.put("quantity","25"); inventory.put("costPerItem","6.95"); inventoryItems.add(inventory); // add dictionary in list } } } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
