• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic