refering to inner classes from imports doesn't work

Nic Ferrier nferrier@tapsellferrier.co.uk
Fri Feb 8 05:44:00 GMT 2002


Cedric Berger <cedric@wireless-networks.com> writes:

> > 
> > 
> >public class A 
> >{ 
> >   public static X createSomething () 
> >   { 
> >     return new X(); 
> >   } 
> > 
> >   public class X 
> >   { 
> >      public void someMethod () 
> >      { 
> >        return; 
> >      } 
> >   } 
> >} 
> > 
> How can the *static* method createSomething() create the *non-static*  
> class A? 
> Cedric 

Sorry, it's another case of leaving stuff out to be economical:

public class A 
{ 
   public static X createSomething () 
   { 
     A something = new A();
     return something.thing();
   } 

   public X thing()
   {
     return new X();
   }
 
   public class X 
   { 
      public void someMethod () 
      { 
        return; 
      } 
   } 
} 

Nic



More information about the Java mailing list