Question: Can you make an ArrayList have multiple data types in Java? This is what I have for my code so far: int userChoice, itemSKU, itemQuantity;
Can you make an ArrayList have multiple data types in Java?
This is what I have for my code so far:
int userChoice, itemSKU, itemQuantity; double itemPrice; String itemTitle; ArrayList
public void addInventory(){ System.out.println("Enter the SKU:"); var.itemSKU = scan.nextInt(); var.inventorySKU.add(var.itemSKU); System.out.println("Enter the title:"); var.itemTitle = scan.next(); var.inventoryTitle.add(var.itemTitle); System.out.println("Enter the price:"); var.itemPrice = scan.nextDouble(); var.inventoryPrice.add(var.itemPrice); System.out.println("Enter the quantity:"); var.itemQuantity = scan.nextInt(); var.inventoryQuantity.add(var.itemQuantity); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
