BTW, the terminology you are looking for is that the "inline" inner
class as you put is called an anonymous inner class while the inner
class that is defined on its own (not at the point of a method call)
but still inside the outer class is usually just called an inner class
but named inner class would also work too.  Both of these have been
available as in Java from the very beginning.

As for why, it is just a matter of taste.  It's sometimes a bit more
concise to just define an anonymous inner class inline, particularly
if the inner class code needs access to variables defined in the
calling method.  With an anonymous inner class you just have to define
the variables or parameters as final and they can be access in the
code of the inner class.  With a named inner class you have to define
extra member variable on the inner class to hold those variables and
probably a constructor that accepts them.

If you find that it results in a ton of code inside the inner class
that all indented, you could just move all that code into a method on
the outer class.  The code in the inner class can access methods and
methods of the outer class.  You can even reference methods and
methods of the outer class that have the same name as something in the
inner class by using the syntax: MyOuter.this.outerMethodCall().
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to