I'm trying to create an Inventory System with a GUI using JSwing and JAVA-WS in Eclipse and I am stuck on trying to turn the Hash into an array. I am in no way an expert in Java, so I came here to ask for help.
Here's the code:
@Override
public InventoryItem [] getAllInventoryItem() {
ArrayList<InventoryItem> items = new ArrayList<InventoryItem>();
InventoryItem item=null;
for(Map.Entry<String, InventoryItem> e : inventories.entrySet())
{
item=new InventoryItem();
item.setBrand(e.getValue().getBrand());
item.setCode(e.getKey());
item.setName(e.getValue().getName());
items.setPrice(e.getValue().getPrice());
items.add(item);
}
return (InventoryItem []) items.toArray(new InventoryItem[items.size()]);
}
But when I call the method:
System.out.println((inventory.getAllInventoryItem()));
This is what comes out:
[Lcom.lansang.inventory.fx.InventoryItem;@123772c4
I also tried:
System.out.println((Arrays.toString(inventory.getAllInventoryItem())));
But still, I dont get the elements inside the array. It only returns this:
[com.lansang.inventory.fx.InventoryItem@123772c4, com.lansang.inventory.fx.InventoryItem@2d363fb3]