DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Dennis Guest

    nested classes again


    sorry, i meant to ask:

    how does an instance of an inner nested class call one of its outer class's
    methods?

  2. #2
    Paul Clapham Guest

    Re: nested classes again


    Dennis <duncand@greigmiddleton.com> wrote in message
    news:38fde5da$1@news.devx.com...
    >
    > sorry, i meant to ask:
    >
    > how does an instance of an inner nested class call one of its outer

    class's
    > methods?


    It just calls it, that's all. Here's an example that compiles and works
    (note that the inner class Inner is calling the womble method of the outer
    class Outer).

    ************** Outer.java ****************
    public class Outer
    {
    public class Inner
    {
    public void mungle() {
    System.out.println("Mungle");
    womble();
    }
    }
    public void womble() {
    System.out.println("Womble");
    }
    }
    ***************** OuterTest.java *******************
    public class OuterTest
    {
    static public void main (String argv [])
    {
    Outer z = new Outer();
    Outer.Inner x = z.new Inner();
    x.mungle();
    }
    }





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