outer class keyword

J

Josef Garvi

What's the keyword for accessing an outer class?
(corresponding thing to "this").

Meaning: when in an anonymous inner class, I want to refer to the outer
class (not its fields), how do I write something like this?

SomeLibrary.someFunction(this.outer, param1, param2);


--
Josef Garvi

"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/

new income - better environment - more food - less poverty
 
M

Michael Borgwardt

Josef said:
What's the keyword for accessing an outer class?
(corresponding thing to "this").

Meaning: when in an anonymous inner class, I want to refer to the outer
class (not its fields), how do I write something like this?

SomeLibrary.someFunction(this.outer, param1, param2);

OuterClassName.this
 
P

P.Hill

Josef said:
SomeLibrary.someFunction(this.outer, param1, param2);

SomeClass.someFunction( OuterClassName.this, param1, param2 );

I used the word OuterClassName, because I wasn't sure if you were
expecting a particular keyword spelled "outer".

Yes, oddly it starts back at the top of the inner/outer relationship
by having you specify the classname instead of providing some type of
relative syntax like I believe you were looking. That means that if
the outer class is inner to another class you migyht have something
like package.SolarSystem.Planet.this to get something inner to Planet
to the containing object. Of course, you probably ought not to nest inner
classes, but it IS possible.

-Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top