| Author |
Example of anonumous class
|
Jayavardhan geepi
Ranch Hand
Joined: Jul 21, 2010
Posts: 66
|
|
Hi, can anybody give me simple example of anonymous classes in java?
Example with custom type is appreciated. Thanks...
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Jayavardhan geepi wrote:Hi, can anybody give me simple example of anonymous classes in java?
first[google it],come up with some example yourself .
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32668
|
|
|
There was a thread about that on JavaRanch yesterday, I think in Java in General.
|
 |
Jayavardhan geepi
Ranch Hand
Joined: Jul 21, 2010
Posts: 66
|
|
Is independent anonymous class possible? I mean , an anonymous class that neither extend any class nor implement any interfaces...
@ Campbell,
There is a thread , but that will not help me.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Jayavardhan geepi wrote:
Is independent anonymous class possible? I mean , an anonymous class that neither extend any class nor implement any interfaces...
No. In the end there is always java.lang.Object as the root of every class hierarchy. But you can make anonymous subclasses of Object. The only thing is, unless you override equals, hashCode, toString or finalize this anonymous subclass will be pointless. Overriding clone is senseless as the class wouldn't implement Cloneable, and all other methods are final. Without overriding any of these 4 methods your anonymous subclass will behave exactly like Object itself.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Example of anonumous class
|
|
|