How do i compare an object with null? From what i've seen right now, at execution an NullPointerException will be thrown :S
For example, if I have a list:
class List
{
private Node data;
private Lista urm;
public List(Node d,Lista u)
{
data = d;
urm = u;
}
public List(Lista l)
{
this.data = l.data;
this.urm = l.urm;
}
public Node getData()
{
return data;
}
public Lista getUrm()
{
return urm;
}
public void setData(Node d)
{
data = d;
}
public void setUrm(Lista u)
{
urm = u;
}
}
, and in another class i have:
class Node {
...
private Lista child;
...
public void addChild(Node c)
{
if(child.getData().equals(null)) child = new Lista(c,null);
else child.setUrm(new Lista(c,null));
}
}
the NullPointerException error will occur at
if(child.getData().equals(null))
I really have to make that check, otherwise my first element of the list will always be null.
Any suggestion appreciated :)