Monday, 11 January 2016

Java Tutorial : Java nested classes(Local Classes)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=U3ZHKfbM84c&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java nested classes(Local Classes)
OuterClass.java
public class OuterClass
{

    private String name = "John";

    public void display(String param)
    {

        String localVar ="Local Variable";
        
        class LocalClass
        {
            String message = "Welcome";

            public void displayMessage()
            {
                System.out.println("message = " + message + " " + name);
                
                System.out.println("localVar = " +localVar);
                
                //localVar = "Change";
                //param ="hi";
                
                System.out.println("param = " +param);
                
            }

        }

        LocalClass localClass = new LocalClass();
        localClass.displayMessage();
    }
}
LocalClassTest.java
public class LocalClassTest
{
    public static void main(String args[])
    {
        OuterClass outerClass = new OuterClass();
        outerClass.display("I am Param");
    }

}
Output
message = Welcome John
localVar = Local Variable
param = I am Param
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/NestedClassDemo-LocalClass-App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/NestedClassDemo-LocalClass-App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d3069ae3fffccb0c6ba4336662b6a2619d880c61/BasicJava/NestedClassDemo-LocalClass-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