Question: please convert the for-each loop into a for loop. im having trouble going back and forth between the two. java public class Inventory { private

please convert the for-each loop into a for loop. im having trouble going back and forth between the two. java please convert the for-each loop into a for loop. im having trouble

public class Inventory { private String stockType; private ArrayList stockQuantity = new ArrayList(); private ArrayList products = new ArrayList(); Scanner scanner = new Scanner(System.in); 1/Get the amount of stock for a given product ID public int getStock(int stockId) { int index; for (Product i : products) { if(i.getId() == stockId) { index = products.indexOf(i); return(stockQuantity.get(index)); } } return -1;|

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!