Boxing (computer programming): Difference between revisions

Content deleted Content added
Egriffin (talk | contribs)
Unboxing - Moved sentence to be next to the code it relates to.
Davidfstr (talk | contribs)
m Boxing: Rephrased: "simple list" -> "array"
Line 5:
 
==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 (computing)|lists]] may have certain [[Method (computer science)|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 listarray 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. One might desire to have a <code>LinkedList</code> of <code>int</code>s, but the <code>LinkedList</code> class only lists objects—it cannot list primitive types.