Casting and dynamic vs static type in Java
- by XpdX
I'm learning about static vs dynamic types, and I am to the point of understanding it for the most part, but this case still eludes me.
If class B extends A, and I have:
A x = new B();
Is the following allowed?:
B y = x;
Or is explicit casting required?:
B y = (B)x;
Thanks!