please refer link
public static void main(String[] args)
{
//add all robots to a list
ArrayList robots = new ArrayList();
robots.add(new WorkerRobot());
robots.add(new GuardRobot());
robots.add(new WateringCan());
//build a wall if you can
for (Object robot: robots)
{
if (robot instanceof WallBuilder)
{
WallBuilder builder = (WallBuilder) robot;
builder.buildWall();
}
}
}
}
inside the if condition checks instanceof WallBuilder
but we interfaces .
And create a refence of WorkerRobots then condtion is always false.
I don't know .
Any one explain how it work in interface