sorry, i meant to ask:
how does an instance of an inner nested class call one of its outer class's
methods?
Printable View
sorry, i meant to ask:
how does an instance of an inner nested class call one of its outer class's
methods?
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();
}
}