outer class keyword

Discussion in 'Java' started by Josef Garvi, May 28, 2004.

  1. Josef Garvi

    Josef Garvi Guest

    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
     
    Josef Garvi, May 28, 2004
    #1
    1. Advertising

  2. Josef Garvi

    Neal Gafter Guest

    OuterClassName.this

    Josef Garvi wrote:
    > 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);
    >
    >
     
    Neal Gafter, May 28, 2004
    #2
    1. Advertising

  3. Josef Garvi wrote:

    > 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
     
    Michael Borgwardt, May 28, 2004
    #3
  4. Josef Garvi

    P.Hill Guest

    Josef Garvi wrote:
    > 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
     
    P.Hill, May 28, 2004
    #4
  5. Josef Garvi

    Tony Morris Guest

    > 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?


    http://www.xdweb.net/~dibblego/java/faq/answers.html#q43

    --
    Tony Morris
    (BInfTech, Cert 3 I.T.)
    Software Engineer
    (2003 VTR1000F)
    Sun Certified Programmer for the Java 2 Platform (1.4)
    Sun Certified Developer for the Java 2 Platform
     
    Tony Morris, May 29, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yamin
    Replies:
    4
    Views:
    16,727
    Yamin
    Oct 24, 2004
  2. Heiko Henkelmann
    Replies:
    2
    Views:
    498
    Heiko Henkelmann
    Apr 27, 2004
  3. Ahan Hsieh
    Replies:
    2
    Views:
    572
    Ahan Hsieh
    Oct 5, 2007
  4. mrstephengross
    Replies:
    4
    Views:
    466
    Diez B. Roggisch
    Feb 27, 2008
  5. Richard Lee
    Replies:
    4
    Views:
    1,060
    James Kanze
    Mar 6, 2008
Loading...

Share This Page