nested classes again


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: nested classes again

Hybrid View

  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();
    }
    }





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