Boxing (computer programming): Difference between revisions

Content deleted Content added
Xaonon (talk | contribs)
slight grammar, style cleanups
m Disambiguate List to List (computing) using popups
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, [[listList (computing)|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. 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.