• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Instantiate Static-Nested class

 
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how a static nested class can be instantiated ?

class Outer{
static Inner{

}


}
case 1: from outer class.

case 2 : outside Outer class.
 
Ranch Hand
Posts: 71
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Static nested class is an just static member of outer class.
Following are the ways to instantiate the static nested class.

case 1. From outer class.

From outer class you can access static class directly by name.
Inner in = new Inner();

case 2. From outside the outer class.
The instantiation of inner class from outside the outer class depends whether it is visible to that class or not.
If it is visible then you can use following syntax.

Outer.Inner oi = new Outer.Inner();

hth

Jagdev
reply
    Bookmark Topic Watch Topic
  • New Topic