Java 5 "box" and "unbox" values

Java 5 "box" and "unbox" values

Postby haretu » Sat Apr 16, 2011 11:08 am

Java5(Java1.5)and later automatically“box”
and ”unbox” values
Integer intObject = new Integer(123);
int intPrimitive = intObject;
double doublePrimitive = 123.45;
Double doubleObject = doublePrimitive;
– The advent of automatic Boxing and automatic Unboxing greatly simplifies code when using Collection and other types of objects
– Boxing and Unboxing is also important since Primitive data and Reference Type data are stored in different places; primitives representing local variables are stored on the stack while objects are stored in heap memory.
haretu
 
Posts: 132
Joined: Sat Jan 08, 2011 9:56 pm

Return to JAVA

Who is online

Users browsing this forum: No registered users and 1 guest

cron