Ben Zaidi wrote:Hello,
It is because, when you declare a class final, then all of its methods are final implicitly. So as data members also i suppose.
Umm i believe my notion is wrong, because if we do something like
c[0] = new CCC();
It works. Additionally, both of the classes are not lying in the same inheritance hierarchy.
If you change the code somehow like this.
In this case, it is compiling fine even with the keyword Final.
I believe after doing a bit of RND, in case of final keywords, the compiler does the bit of optimization, means the check of casting
which mostly happens at Runtime in non-final cases are checked at compile time in case of final keywords. Correct me please if
i am wrong.
Ben,
--Lost in preparation of SCJP and SCWCD--
"Start writing a new chapter, for if you live by the book you'll never make history." (Ben Sobel)