OuterClass.java
------------------------------------------------------------
package org.developerssolutions;
public class OuterClass {
public void method(){
System.out.println("OuterClass.Method1");
}
class InnerClass{
public void method(){
System.out.println("OuterClass.InnerClass.Method1");
}
class InnerInnerClass{
public void method(){
System.out.println("OuterClass.InnerClass.InnerInnerClass.Method1");
}
}
}
}
Test.java
-------------------------------------------------------------------------------
package org.developerssolutions;
public class Test {
public static void main(String[] args) {
//Outer Class Object
OuterClass oc=new OuterClass();
//Inner Class Objects
OuterClass.InnerClass ic=oc.new InnerClass();
OuterClass.InnerClass.InnerInnerClass oii=ic.new InnerInnerClass();
oc.method();
ic.method();
oii.method();
}
}
Output:
-----------------------------------------------------------------------------------------
OuterClass.Method1
OuterClass.InnerClass.Method1
OuterClass.InnerClass.InnerInnerClass.Method1
------------------------------------------------------------
package org.developerssolutions;
public class OuterClass {
public void method(){
System.out.println("OuterClass.Method1");
}
class InnerClass{
public void method(){
System.out.println("OuterClass.InnerClass.Method1");
}
class InnerInnerClass{
public void method(){
System.out.println("OuterClass.InnerClass.InnerInnerClass.Method1");
}
}
}
}
Test.java
-------------------------------------------------------------------------------
package org.developerssolutions;
public class Test {
public static void main(String[] args) {
//Outer Class Object
OuterClass oc=new OuterClass();
//Inner Class Objects
OuterClass.InnerClass ic=oc.new InnerClass();
OuterClass.InnerClass.InnerInnerClass oii=ic.new InnerInnerClass();
oc.method();
ic.method();
oii.method();
}
}
Output:
-----------------------------------------------------------------------------------------
OuterClass.Method1
OuterClass.InnerClass.Method1
OuterClass.InnerClass.InnerInnerClass.Method1
Comments
Post a Comment