Java
Why won’t my arrayList add more than the first Item?
Below is the method i am using. It works fine for the first. Butas soon i test it for the second item in the array, it comes backnull.
Thank you in advance
—————————————————————————————————————————————————————————————————————————–
Methods addItem & findItem
public voidaddItem(unisa.library.Item newItem) throwsDuplicateItemException {
unisa.library.Item tempItem;
try {
tempItem = findItem(newItem.ID);
if(tempItem == null) {
itemList.add(newItem);
}
else {
throw newDuplicateItemException(newItem.ID + “already exists”);
}
} catch (ItemNotFoundException e) {
itemList.add(newItem);
}
}
public unisa.library.Item findItem(String id)throws unisa.library.ItemNotFoundException {
//Method used to locate an Item based off the id provided in theparameters
// First find if the list is empty, if it is then throwexception
if(itemList.isEmpty())
throw newItemNotFoundException(id + “Cannot be found”);
try {
//try to locate
PayPal Gateway not configured
PayPal Gateway not configured