Boxing (computer programming): Difference between revisions

Content deleted Content added
add {{seealso|Object (computer science)}}
fmt
Line 1:
{{Article issues|expert=Computer science|unreferencedrefimprove=August 2009|cleanup=November 2006|date=August 2009}}
{{Generalize|date=October 2009}}<!-- only talks of Java; there are complaints on the talk page about this -->
 
Line 31:
</source>
 
Compilers prior to 5.0 would not accept the last line. <code>Integer</code>s are reference objects, on the surface no different from <code>List</code>, <code>Object</code>, and so forth; mathematical operators such as <code>+</code> were not meaningfully defined for references. As of J2SE 5.0, the <code>Integer</code>s <code>i</code> and <code>j</code> are unboxed into <code>int</code>s, the two are added, and then the sum is autoboxed into a new <code>Integer</code>. <ref>[http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html java.sun.com Java language guide entry on autoboxing]</ref>
 
===Unboxing===
Line 53:
Console.Writeline(j); //outputs "42"
</source>
 
==References==
{{reflist}}
 
{{DEFAULTSORT:Object Type (Object-Oriented Programming)}}