I have created a Boolean method called trainer()
inside the class Trainer
which extends the abstract class Employees()
. This method returns true if the Employee inside the list is a trainer and then it prints it. But when I execute the program there seems to be an exception with the Boolean method trainer
. As for the ItemEmployees
this is a class which expands a class called Item()
.
If needed I can provide both their codes. But I do not think the problem is in those classes.
The following is written within the main class:
Node firstnode = list.getFirst();
ItemEmployees t = (ItemEmployees) firstnode.getValue();
for(Node tmp=firstnode; tmp!=null; tmp=tmp.getNext())
{
if(tmp.getValue()!=null)
{
Employees e = t.keye();
if( e.trainer() )
{
e.print();
}
}
}
Now this is inside the Trainer()
class:
public boolean trainer()
{
return true;
}
Exception
Exception in thread "main" java.lang.NullPointerException at MainClass.main(MainClass.java:348)
Line 348 is
if( e.trainer() )