🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14435

Re: Inner Class Problem

#14435
From: Paul Furbacher [TeamB]
Date: Wed, 08 Sep 1999 00:00
34 lines
1395 bytes
Dillan Fernando wrote:

> I have a public class which has two inner classes. I want to write a general
> method (function) which can be calles by both inner classes.
> I thought of writting this class in the parent class.
> 
> How can I call a method in the parent class from an inner class.

Given 

  public class A { 
     public A() { 
        B b = new B();
        b.doWork();
     }

     public void doSomething() {
        System.out.println("something was done";
     }

     public class B {
       public B() {  }
       public void doWork() {
          // work is calling A's doSomething()
          A.this.doSomething(); 
       }
     }
  }

For a succinct discussion of inner (member) classes, see
"Java in a Nutshell, 2d. ed.", by David Flanagan. 


Paul Furbacher
Technical Details
Message-ID: <37D6C5F1.CCD91232@bilbo.bio.purdue.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7r6b5b$iuo13@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,974bb0ab5a146595,start
X-Google-Attributes: gidf74b3,public
From: "Paul Furbacher [TeamB]" <pf@bilbo.bio.purdue.edu>
Subject: Re: Inner Class Problem
Date: 1999/09/08
Message-ID: <37D6C5F1.CCD91232@bilbo.bio.purdue.edu>
X-Deja-AN: 522653359
Content-Transfer-Encoding: 7bit
References: <7r6b5b$iuo13@forums.borland.com>
Content-Type: text/plain; charset=us-ascii
Organization: Reverse Alchemy, Inc.
Mime-Version: 1.0
Reply-To: pf@bilbo.bio.purdue.edu
Newsgroups: borland.public.jbuilder.java.language