Syntax for accessing method of enclosing class with same name as one of this's methods


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Syntax for accessing method of enclosing class with same name as one of this's methods

Hybrid View

  1. #1
    Luchador Guest

    Syntax for accessing method of enclosing class with same name as one of this's methods


    class A{
    public void doSomething(){...}
    class B{
    public void doSomething(){...}
    public void somethingElse(){
    //how do I call A's do something here?
    }
    }
    }

    Thanks for the help

  2. #2
    Paul Clapham Guest

    Re: Syntax for accessing method of enclosing class with same name as one of this's methods

    Not very good design to name your methods that way, but try
    "A.doSomething()".

    PC2

    "Luchador" <rcruz@cs.utexas.edu> wrote in message
    news:3b5a49e2$1@news.devx.com...
    >
    > class A{
    > public void doSomething(){...}
    > class B{
    > public void doSomething(){...}
    > public void somethingElse(){
    > file://how do I call A's do something here?
    > }
    > }
    > }
    >
    > Thanks for the help




  3. #3
    Luchador Guest

    Re: Syntax for accessing method of enclosing class with same name as one of this's methods


    Why is this not good design? Actually the real problem is both the enclosing
    class and inner class inherit from Component. I want to use one of its(Component's)
    methods for the enclosing class. Your suggestion gives an error since the
    method is not static.



    "Paul Clapham" <pclapham@core-mark.com> wrote:
    >Not very good design to name your methods that way, but try
    >"A.doSomething()".
    >
    >PC2
    >
    >"Luchador" <rcruz@cs.utexas.edu> wrote in message
    >news:3b5a49e2$1@news.devx.com...
    >>
    >> class A{
    >> public void doSomething(){...}
    >> class B{
    >> public void doSomething(){...}
    >> public void somethingElse(){
    >> file://how do I call A's do something here?
    >> }
    >> }
    >> }
    >>
    >> Thanks for the help

    >
    >



  4. #4
    Paul Clapham Guest

    Re: Syntax for accessing method of enclosing class with same name as one of this's methods

    Okay, so try A.this.doSomething().

    PC2

    "Luchador" <rcruz@cs.utexas.edu> wrote in message
    news:3b5b2adf$1@news.devx.com...
    >
    > Why is this not good design? Actually the real problem is both the

    enclosing
    > class and inner class inherit from Component. I want to use one of

    its(Component's)
    > methods for the enclosing class. Your suggestion gives an error since the
    > method is not static.





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center