for (int i = 0; i < row.findRowNumber(); i++) {
String[] itemTokens = rawInventory[i].split("\\s");
inventory[i] = new Item(itemTokens[0], Integer.parseInt(itemTokens[1]));
}
for (int i = 0;i < inventory.length; i++) {
System.out.println(inventory[i]);
}
我想訪問名爲inventory的對象結構數組。如果我測試println它將出現爲:訪問結構數組
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
那麼我該如何處理java中的對象數組?謝謝
您已經訪問對象的數組和印刷引用。你期望輸出什麼? –
它假設出來爲:蘋果40葡萄30等等 – nfnmy
然後,你必須相應地訪問對象的字段,並打印它們或覆蓋類'toString'方法。 Java無法知道你想如何打印字段。 –