STATIC INNER CLASS
whenever any class is defined inside the scope of another class using 'static' keyword then it is class static inner class.
# how call inner class
OuterClassName.InnerClassName
# following characteristics are:
1) It can be instantiated independently means object of outer class is not required for
whenever any class is defined inside the scope of another class using 'static' keyword then it is class static inner class.
# how call inner class
OuterClassName.InnerClassName
# following characteristics are:
1) It can be instantiated independently means object of outer class is not required for
instantiation of static inner class.
OuterClassName ref = new OuterClassName()
2) It can directly used the reference of priavte static member of its outer class.
OuterClassName ref = new OuterClassName()
2) It can directly used the reference of priavte static member of its outer class.
class Outer
{
priavte static int a=10;
class Inner
{
public void display()
{
System.out.println("access value of a"+a);// private member of class call in inner class
}
}
---------------------------------------------------------------------------------
JRE MAKE FOLLOWING CHANGE
1) inside outer class
jre create accessor method for each priavte static datamember inside outer class
static int accessor$0000()
{
return a;
}
2) inside inner class
jre convert the call of priavte static data member with accessor method of its outer class
# method of inner call
public void display()
{
System.out.println("access value of a"+Outer.accessor$000());
}
nonstatic class on next post.....
{
priavte static int a=10;
class Inner
{
public void display()
{
System.out.println("access value of a"+a);// private member of class call in inner class
}
}
---------------------------------------------------------------------------------
JRE MAKE FOLLOWING CHANGE
1) inside outer class
jre create accessor method for each priavte static datamember inside outer class
static int accessor$0000()
{
return a;
}
2) inside inner class
jre convert the call of priavte static data member with accessor method of its outer class
# method of inner call
public void display()
{
System.out.println("access value of a"+Outer.accessor$000());
}
nonstatic class on next post.....
Comments
Post a Comment