I'm trying to learn chain of responsibility pattern in Java, In below code if the successor does not exist, it gives a NullPointerException
. I want to check if the successor exists like this
if(this.sucessor exists) {
this.successor.check(Home)
}
How can I do this?
public void next(HomeStatus Home){
this.successor.check(Home);
}