Re: inner class and static
"jim" <jseers@xxxxxxxxx> wrote in message
news:1153161800.679433.165030@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I was told that the variable accessed inside a anonymous inner class
needs to be static.
An inner class (whether anonymous or not) may access the instance variables
of the outer class and it can access the local variables of the method that
instantiates it, provided they are final.
Cheers,
Matt Humphrey matth@xxxxxxxxxxxxxx
http://www.iviz.com/
.
Relevant Pages
- Re: Updating GUI & Running Program (AND accessing common variables!)
... >anonymous inner class cannot access variables from the outer class unless ... >have no problem accessing the variables in the outer class. ... Finalize is not the same as final. ... have local variables. ... (comp.lang.java.gui) - Re: Updating GUI & Running Program (AND accessing common variables!)
... >>You need to clarify what you mean by 'in the outer class'. ... >>An anymous inner class relies on some compiler magic. ... >>copies the values of all local variables into corresponding variables of ... an anonymous inner class can only access local ... (comp.lang.java.gui) - Re: inner class and static
... variables of the outer class and it can access the local variables of the ... Though a *static* inner class can only access static field of its enclosing ... class (and can only call static methods of that class); ... (comp.lang.java.programmer) - Re: Need a way for forgetful developers
... Almost every developers define classes and use them in anothers. ... If A is a class and B uses A then we can name B as outer class and A as inner class. ... In its initialize method, outer class should call the initialize method of every inner class objects, ... (microsoft.public.vc.language) - Re: Trying to create a working internal confirm JOptionPane
... inner class, because it is an inner class, belongs to an object of the outer ... That means there is an outer class "this", ... It is not a static variable reference, but a completely different part of the Java language. ... Your mistake was thinking that one part of the Java language should follow rules from another part. ... (comp.lang.java.help) |
|