Click here to watch in Youtube :
https://www.youtube.com/watch?v=Oq1rAsgBr68&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java initialize using final method |
public class Parent { public int capacity = initializeInstanceVariable(10); protected final int initializeInstanceVariable(int value) { System.out.println("Inside final method."); capacity = value; return capacity; } }
public class Child extends Parent { public static void main(String args[]) { Child child = new Child(); System.out.println("capacity : " + child.capacity); /* * Subclass reusing the initialization method. */ child.initializeInstanceVariable(200); System.out.println("capacity : " + child.capacity); } }
Inside final method. capacity : 10 Inside final method. capacity : 200
https://sites.google.com/site/javaee4321/java/InstanceMemberInitializeDemo-Final-App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/InstanceMemberInitializeDemo-Final-App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/41d9dfe14fcf9b8b617da7211fce54dcabe49f5c/BasicJava/InstanceMemberInitializeDemo-Final-App/?at=master
See also:
No comments:
Post a Comment