Devaka Cooray wrote:
The reference type of 'r1' is NOT unknown - it is Runnable.
The casting attempt for t1 does not give you a compile time error as you are casting within a single hierarchy root - you are casting from Runnable to Thread, and Thread is-a Runnable.
sir if i am following your concept then there will be exception ...
but K&B book says that there is
Plain-Old Anonymous Inner Classes, Flavor Two.
Anonymous class would be an implementer of the interface Runnable
it's not instantiating a Runnable object, it's creating an instance of a new, anonymous, implementer of Runnable.
Declare a reference variable
r1 of type Runnable that, obviously, will refer to an object from a class that implements the Runnable interface.
so there is a Anonymous class that implement Runnable
like : class uvs implements Runnable
so what is diffrence in root hierarchy
sir
please clear my concept ....
Thanks