Java Unboxing Example
Chapter:
Miscellaneous
Last Updated:
23-03-2017 19:47:42 UTC
Program:
/* ............... START ............... */
public class JavaUnboxingExample {
public static void main(String args[]) {
Integer i = new Integer(50);
int a = i;
System.out.println(a);
}
}
/* ............... END ............... */
Output
Notes:
-
The automatic conversion of wrapper class type into corresponding primitive type, is known as Unboxing.
- Autoboxing and unboxing can make your code easier to read.
- Excessive, unnecessary auto-boxing and auto-unboxing can hinder your performance.
- Using collections of auto-boxed values uses a lot more memory than a comparable double[] for example.
Tags
Unboxing Example, Java, Miscellaneous