Click here to watch in Youtube :
https://www.youtube.com/watch?v=69dpnBRbb3c&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java Static Nested Classes |
public class OuterClass { private int outerVariable = 10; private static int staticOuterVariable = 200; public void outerDisplay() { System.out.println("outerDisplay method has been called..."); } public static void staticOuterDisplay() { System.out.println("staticOuterDisplay method has been called..."); } static class StaticNestedClass { int innerVariable = 2000; public void innerDisplay() { System.out.println("innerDisplay method has been called..."); System.out.println("innerVariable : " + innerVariable); System.out.println("staticOuterVariable : " + staticOuterVariable); staticOuterDisplay(); // System.out.println("outerVariable : " + outerVariable); // outerDisplay(); } } }
public class StaticNestedClassTest { public static void main(String[] args) { OuterClass.StaticNestedClass nestedObj = new OuterClass.StaticNestedClass(); nestedObj.innerDisplay(); } }
innerDisplay method has been called... innerVariable : 2000 staticOuterVariable : 200 staticOuterDisplay method has been called...
https://sites.google.com/site/javaee4321/java/NestedClassDemo-Static-App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/NestedClassDemo-Static-App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/41d9dfe14fcf9b8b617da7211fce54dcabe49f5c/BasicJava/NestedClassDemo-Static-App/?at=master
See also:
No comments:
Post a Comment