Tuesday, 5 January 2016

Java Tutorial : Java Static Nested Classes


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
OuterClass.java
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();
        }
    }

}
StaticNestedClassTest.java
public class StaticNestedClassTest
{

    public static void main(String[] args)
    {
        OuterClass.StaticNestedClass nestedObj = new OuterClass.StaticNestedClass();
        nestedObj.innerDisplay();
    }

}
Output
innerDisplay method has been called...
innerVariable : 2000
staticOuterVariable : 200
staticOuterDisplay method has been called...
Click the below link to download the code:
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:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge