I am trying to make an inventory system and am using the following code. I tried adding numberOfItems-- because I thought that was the problem but that doesn't seem to be it.
public static void delete(String title) {
    for(int i = 0; i < numberOfItems; i++) {
        if(newItem.get(i).getTitle().equalsIgnoreCase(title)){
            newItem.remove(i);
        }
    }
}
case 5:
    String name = "";
    System.out.println("What is the name of the item?");
    name = userInput.nextLine();
    delete(name);
    numberOfItems--;
    break;
 
     
    