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) |
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(); } }
public class LocalClassTest { public static void main(String args[]) { OuterClass outerClass = new OuterClass(); outerClass.display("I am Param"); } }
message = Welcome John localVar = Local Variable param = I am Param
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:
No comments:
Post a Comment