Hey guys,
I have a question about casting in this code from one of the devaka K examlabs........
Kinda confused with the whole typecasting thing.......
class B extends A{}
final class C extends B{}
class A{
public static void main(
String args[])
{
A a = new B();
B b = new B();
C c = new C();
C[] ca = null;
a = b;
b = c;
A a1 = (B) c;
Runnable r1 = (Runnable) a; //1
Runnable [] ra1 = null;
A r2 = (A) r1;
A[] aa1 = (A[])r1; //17
A[] aa2 = (A[])ra1; //18
ra1 = (Runnable[]) ca; //19
}
}
Why is line 19 giving compile time error when line 18 isn't?
Thanks in advance!!!