Hi guys, I came across a question saying that "An anonymous inner class can be created inside a method" is false.... where else can it be created then? Thanks
Sean <br />SCJP2, SCJP2p1.4, SCWCD
Bin Zhao
Ranch Hand
Joined: Oct 04, 2000
Posts: 73
posted
0
"An anonymous inner class can be created inside a method" is TRUE. Consider the following code: public A aMethod(){ return new A(){ .... }; } Here in method aMethod(), an anonymous class wich extends class A is defined.
sean cee
Ranch Hand
Joined: Oct 24, 2000
Posts: 115
posted
0
Bin, you are right. anoymous inner class CANNOT be created anywhere outside the method ... right? thanks.
Subha Guhan
Greenhorn
Joined: Nov 06, 2000
Posts: 23
posted
0
Sean
Are you reproducing the question verbatim? It is not only possible to create it inside the method but also in the following ways.
please correct me if I am wrong [This message has been edited by Subha Guhan (edited November 07, 2000).] [This message has been edited by Subha Guhan (edited November 07, 2000).]
sean cee
Ranch Hand
Joined: Oct 24, 2000
Posts: 115
posted
0
Hi, Subha, You are right. your code make good sense. Thanks