You have a very strange architecture here, my friend. You should not use a generic Object everywhere, but actual types. First:
public Object getAllInventoryItems() { //return InventoryItems; return this.InventoryItems.toArray(); }
Why not just return the List itself?
public List<Item> getAllInventoryItems() { return this.InventoryItems; }
Also change this:
List<Item> InventoryItems = new ArrayList<Item>();
and this:
public void setInventoryItems(Item inventoryItems) { this.InventoryItems.add(inventoryItems); }
The List iteration now runs smoothly:
public static void main(String[] args) {
Btw, I changed Items to Item out of habit. The class name should point to a single entity, therefore, by convention, it is the only one.
Now don't do it wrong, but you may have gotten off the wrong foot with Java, so I highly recommend this reading: http://www.mindview.net/Books/TIJ/ This worked for me when I started with Java, maybe others can offer good sources.
Tudor source share