[Solved] return Array[] or return null Java


Probably this line itemInventory.get(j).getName().equalsIgnoreCase(n) == true causes NPE. Make sure that itemInventory.get(j) is not null before you get the name:

if(itemInventory.get(j)!=null) //only then get the name
    if(itemInventory.get(j).getName().equalsIgnoreCase(n))

6

solved return Array[] or return null Java