but what is the use of the code when i am not able to access it. How can i access it?
Joined: Oct 13, 2005
You instantiate an anonymous class the same way you instantiate any class, with the new operator/keyword. There is an example of how it is done in this post.
You assign it to a reference the same way you assign to any other reference, like this: Foo f = . . . You call its methods exactly the same way you call methods on any other reference, like this f.bar(123, 456); You could call its run() method like this r.run();, but you would actually say something like new Thread(r).start();