“int cannot be dereferenced” in Java

id is of primitive type int and not an Object. You cannot call methods on a primitive as you are doing here :

Try replacing this:

        if (id.equals(list[pos].getItemNumber())){ //Getting error on "equals"

with

        if (id == list[pos].getItemNumber()){ //Getting error on "equals"

Leave a Comment