Click here to watch in Youtube :
https://www.youtube.com/watch?v=VMr3oaalVoE&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java wrapper class(Autoboxing and unboxing) |
Java Tutorial : Java wrapper class(Autoboxing and unboxing) |
public class PrimitiveToWrapperExample { public static void main(String[] args) { /* * Primitive to Wrapper Example. * * Converting int into Integer */ int intValue = 300; Integer integerObj1 = Integer.valueOf(intValue); System.out.println("integerObj1 = " + integerObj1); /* * Autoboxing, now compiler will write * Integer.valueOf(a) internally */ Integer integerObj2 = intValue; System.out.println("integerObj2 = " + integerObj2); } }
integerObj1 = 300 integerObj2 = 300
public class WrapperToPrimitiveExample { public static void main(String[] args) { /* * Wrapper to Primitive * * Converting Integer to int */ Integer integerObj = new Integer(3); System.out.println("integerObj = " + integerObj); /* * converting Integer to int */ int i = integerObj.intValue(); System.out.println("i = " + i); /* * Unboxing, now compiler will write a.intValue() * internally */ int j = integerObj; System.out.println("j = " + j); } }
integerObj = 3 i = 3 j = 3
https://sites.google.com/site/javaee4321/java/WrapperClassDemo_Autoboxing_Unboxing_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/WrapperClassDemo_Autoboxing_Unboxing_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d0559102086f9677d57877fbba43556aca45fc19/BasicJava/WrapperClassDemo_Autoboxing_Unboxing_App/?at=master
See also:
Thank you for sharing valuable information.
ReplyDeleteJava Online Training
I really liked your blog article. Great.
ReplyDeleteonline training in java
online training on java