| Author |
anonymous class in methods
|
Arun Kumarr
Ranch Hand
Joined: May 16, 2005
Posts: 508
|
|
what do you call a anonymous class defined inside a method??? For eg; What do I call the class inside mtd() in class A ??? class B{ public void mtdb(){ System.out.println("hey1"); } } public class A{ public static void main(String sinful[]){ A a= new A(); B b = new B(); a.mtd(); b.mtdb(); } void mtd(){ B b = new B(){ public void mtdb(){ System.out.println("hey"); } }; b.mtdb(); }
|
If you are not laughing at yourself, then you just didn't get the joke.
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
I don't know a more specific term than "anonymous inner class"...
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
Arun Kumarr
Ranch Hand
Joined: May 16, 2005
Posts: 508
|
|
|
can we call it anonymous local class.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
Originally posted by Arun Kumarr: can we call it anonymous local class.
You could; you could also call it "Harold", if you wanted. But officially, it's an anonymous inner class, and that's what everyone calls it. There is no such thing as a "non-local anonymous class", right? So the "local" would be redundant.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Arun Kumarr
Ranch Hand
Joined: May 16, 2005
Posts: 508
|
|
|
when I said "local" I meant "method-local" anonymous inner class.
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
Well, as they don't work differently from "non-method-local" ones, why would you want to give them a special name?
|
 |
Mr. C Lamont Gilbert
Ranch Hand
Joined: Oct 05, 2001
Posts: 1170
|
|
Plus its not method local as it can be accessed as if it were class local, i.e. anonymous inner class. correct me if I am wrong here.
|
 |
 |
|
|
subject: anonymous class in methods
|
|
|