/** * Casting example, with issues * @author gtowell * Created: Sep 2020 */ public class Caster { /** * Define a class that exists only within Caster. * We will do this a lot this semester. * Note that this class does exactly nothing beyond Object */ private class A {} /** * Another class only within Caster. This one extends A! */ private class B extends A { /** A private variable. Note that this is only in B, not A */ private int bvar; /** A constructor, sets the value of the private variable. */ public B() { bvar = 1; } } public void tester() { A a = new A(); B b = new B(); A aa = b; B bb = (B)a; } }