Member Inner Class A class created within class and outside method.
Anonymous Inner Class A class created for implementing interface or extending class. Its name is decided by the java compiler.
Local Inner Class A class created within method.
Static Nested Class A static class created within class.
Nested Interface An interface created within class or interface.
A non-static class that is created inside a class but outside a method is called member inner class.
Syntax:
class Outer{
//code
class Inner{
//code
}
}
class TestMemberOuter1{
private int data=30;
class Inner{
void msg(){System.out.println("data is "+data);}
}
public static void main(String args[]){
TestMemberOuter1 obj=new TestMemberOuter1();
TestMemberOuter1.Inner in=obj.new Inner();
in.msg();
}
}
import java.io.PrintStream;
class Outer$Inner
{
final Outer this$0;
Outer$Inner()
{ super();
this$0 = Outer.this;
}
void msg()
{
System.out.println((new StringBuilder()).append("data is ")
.append(Outer.access$000(Outer.this)).toString());
}
}
No comments:
Post a Comment