public Node searchData(String fullName)
{
Node current = root;
while(current.fullName != fullName)
{
if(fullName.compareTo(current.fullName) < current.fullName.compareTo(fullName))
{
current = current.leftChild;
}
else if(fullName.compareTo(current.fullName) > current.fullName.compareTo(fullName))
{
current = current.rightChild;
}
else
current = null;
}
return current;
}
Whenever I enter a name into the program I receive a null pointer exception error. The program itself initializes a binary tree with a text-file and that already works but i'm not sure why it keeps crashing when I try to search for the node itself. I know the nodes already exist but can't figure out why it says that its null.