can someone please explain to me Casting with examples.
/** In Actor subclass */ // case 1: assigning the world to a field that holds a World object World world = getWorld(); // "world.gameOver();" will not work as "world" is not cast as a MyWorld object, but ((MyWorld)world).gameOver(); // will work // case 2: assigning the world to a field that holds a MyWorld object MyWorld world = (MyWorld) getWorld(); world.gameOver(); // case 3: casting and calling the method in one statement ((MyWorld) getWorld()).gameOver();