以下方法始终返回 NULL:
public SalesItem findItem(String itemCode){
// to be implemented
Cart cart = new Cart();
SalesItem[] item;
item = new SalesItem[1];
item[0] = null;
for (int i = 0; i < size -1; i++) {
if (itemCode.equals(items[i].getItemCode())) {
item[0] = items[i];
System.out.println("Item - " + item +" is added to the shopping cart.");
cart.addItem(items[i]);
}
else {
item[0] = null;
}
}
return item[0];
有谁知道我的代码有什么问题?