-
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
|
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
|
Bookmarks