Content deleted Content added
Matt Crypto (talk | contribs) m "by the computer" is not needed |
slight grammar, style cleanups |
||
Line 4:
==Boxing==
'''Boxing''' is to place a primitive type within an object so that the primitive can be used as an object, in a language where there is a distinction between a primitive type and an object type. For example, [[list|lists]] may have certain [[methods]] which [[arrays]] might not, but the list might also require that all of its members be objects. In this case, the added functionality of the list might be unavailable to a simple list of numbers.
For a more concrete example, in Java, a {{Javadoc:SE|java/util|LinkedList}} can change its size, but an array must have a fixed size.
To get around this,
===Autoboxing===
Autoboxing is the term for treating a primitive type as an object type without any extra code.
For example, as of J2SE 5.0, Java will now allow
This action is called ''autoboxing'', because it is boxing that is done automatically and implicitly instead of requiring
===Unboxing===
Unboxing is the term for treating an object type as a primitive type without any extra code.
Line 26 ⟶ 29:
Integer k = i + j;
int i = 9;
Line 32 ⟶ 35:
int k = i + j;
As of J2SE 5.0, the first example is now treated just like the second example. The <code>Integer</code> is
[[Category:Data types]]
|