OT: Re: [Tutor] Apply() [function calling depends on end parenthese s]

Erik Price erikprice@mac.com
Fri Feb 7 07:50:02 2003


On Friday, February 7, 2003, at 07:08  AM, alan.gauld@bt.com wrote:

> It certainly doesn't, which is one reason they had to introduce the
> dreadful inner class stuff!
>
> You define a bunch of inner classes(*) that have a single method
> then you can instantiate whichever inner class you need then
> call it's method - yech!

I've never done anything like that in Java, actually.  Part of it must 
be that I'm still a relative newcomer to Java, too.  I thought that 
Java's inner classes were a means of simulating multiple inheritance.  
(When implementing multiple interfaces won't do the trick because you 
need some kind of implementation functionality from the parent class.)

Because the inner class has access to the enclosing class's members and 
operations, you can have the inner class inherit from a diff't class 
than the enclosing class and write the whole thing to do whatever it is 
you need from both parent classes.

And I thought that anonymous inner classes were primarily used for code 
organization, say you need an event handler for some control X, but you 
don't use it anywhere else in the application, then why bother making a 
separate public class just for that one case -- just tuck it inside the 
class that needs it, etc.

I have not had opportunity to use inner classes in the way that you 
describe (to make dynamic callables), but yes, it does sound like a lot 
more work than the Python way.


Erik





-- 
Erik Price

email: erikprice@mac.com
jabber: erikprice@jabber.org