Can anybody explain why the if statement below evaluates false?
public void addShapeToWhiteboard(PolyLine shape)
{
Window.alert("2");
if(shape instanceof PolyLine)
{
Window.alert("3");
this.whiteboard.add((PolyLine)shape);
Window.alert("3.5");
}
this.whiteboard.draw();
Window.alert("4");
}
it takes in a “PolyLine” object, but instanceof returns false because I get an alert of “2” followed by an alert of “4” and have no clue how it’s even possible.
Maybe shape is null? instanceof returns false in such a case.