I'm making a store in java and I'm trying to add a new item to an array, but I can't figure out how to make it work. add.items(i); won't work because that's only for ArrayList, and a requirement for this task is that I have to use an array. The purpose of this function is it checks if there is an empty space in the array, which has a maximum size of 10, and it adds an item if it's not full.
public boolean addItem (Item i){
for (int i = 0; i < items.length; i++) {
if (items[i] == null) {
add.items(i);
return true;
}
return false;
}
}
add.items(i);won't work for an ArrayList either.