So I have a method that is checked when a user runs a command, well I get getting this wretched error that it’s returning a NullPointer…
Heres my method,
public boolean openReferal(String name) {
for(String s : m.refferalSessions) {
if(s.equalsIgnoreCase(name)) {
return true;
}
}
return false;
}
And heres how i’m implementing it…
if(check.openReferal(sender.getName() + ":" + args[0])) {
sender.sendMessage(openReferal);
return true;
}
A
NullPointerExceptionmeans that you are dereferencing a null variable somewhere. The stack trace will tell you exactly which line is causing the problem, and from that you can deduce which variable is set to null.From your code, there are only a few suspects:
m,m.referralSessions,checkandsender. Check that they are all initialized properly, and use the information in the exception to help track down the problem.