wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inner class" Watch "inner class" New topic
Author

inner class

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi!
How I can create an object of static inner class if is within a another static inner class?
Thanks in advance.
April.Johnson
Ranch Hand

Joined: May 02, 2001
Posts: 48
Check out the following code to see if it answers your question.

April
Seema Poddar
Greenhorn

Joined: Aug 08, 2001
Posts: 2

Hi,
I just wanted to bring forward this Golden Rule :-
For an Inner class, the Outer class just
acts like a package and thats why, one needs to
follow Fully Qualified Naming Convention, just as we
use for naming Packages or Importing classes.
Consider this example :-
class Outer
{
static class Inner
{
static class InnerMost
{
int x = 5;
}
}
public static void main(String args[])
{
Outer.Inner.InnerMost myInn = new Outer.Inner.InnerMost();
System.out.println("x = " + myInn.x);
}
}

Notice how the InnerMost class has been instantiated. The compiler will not resolve the symbol "class InnerMost" until, it gets the Fully Qualified Name, where it is located.

------------------
Regards
Seema


Regards<BR>Seema
 
GeeCON Prague 2014
 
subject: inner class