Boxing (computer programming): Difference between revisions

Content deleted Content added
m Ced
FlyHigh (talk | contribs)
m Disambiguation, link to method
Line 6:
==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 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.