Casting and dynamic vs static type in Java
Posted
by XpdX
on Stack Overflow
See other posts from Stack Overflow
or by XpdX
Published on 2010-04-20T04:55:45Z
Indexed on
2010/04/20
5:03 UTC
Read the original article
Hit count: 369
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!
© Stack Overflow or respective owner