DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4

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.





Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links