I have this method in my code
public boolean has(AnyType x){
for(int i=0; i<items.length; i++)
if(items[i] == x)
return true;
return false;
}
and I want to rewrite the if statement to use the compareTo() method, and according to what I remember it should be something like this:
if(items[i].compareTo(x) == 0)
But that is giving me an error
Exception in thread "main" java.lang.NullPointerException
Any ideas of what I might be doing wrong??