-
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?
-
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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|