Primitive wrapper class in Java: Difference between revisions

Content deleted Content added
m fixed wikilink for renamed article
Add discusssion of Void class
Line 1:
In the [[Java programming language]], a '''primitive wrapper class''' is one of eight classes provided in the {{Javadoc:SE|package=java.lang|java/lang}} [[Java package|package]] to provide [[object-oriented programming|object]] [[Method (computer science)|methods]] for the eight [[primitive type]]s. All of the primitive wrapper classes in Java are [[immutable object|immutable]]. [[J2SE]] 5.0 introduced [[autoboxing]] of primitive types into their wrapper object, and automatic unboxing of the wrapper objects into their primitive value—the implicit conversion between the wrapper objects and primitive values.
 
[[object type|Wrapper classes]] are used represent primitive values when an {{Javadoc:SE|java/lang|Object}} is required. The wrapper classes are used extensively with {{Javadoc:SE|java/util|Collection}} classes in the {{Javadoc:SE|package=java.util|java/util}} package and with the classes in the {{Javadoc:SE|package=java.lang.reflect|java/lang/reflect}} [[Reflection (computer science)|reflection]] package.
 
The primitive wrapper classes and their corresponding primitive types are:
Line 26:
 
The <code>Byte</code>, <code>Short</code>, <code>Integer</code>, <code>Long</code>, <code>Float</code>, and <code>Double</code> wrapper classes are all [[subclasses]] of the {{Javadoc:SE|java/lang|Number}} class.
 
== Void ==
 
Although it is not a wrapper class, the {{Javadoc:SE|java/lang|Void}} class is similar in that it provides an object representation of the [[void type|<code>void</code>]] return type. The <code>Void</code> class is an uninstantiable placeholder class used by the [[Java Platform, Standard Edition#java.lang.reflect|java.lang.reflect]] [[application programming interface|API]] to hold a reference to the {{Javadoc:SE|java/lang|Class}} object representing the [[Java keyword]] <code>void</code>.
 
== See also ==
 
* [[Java Platform, Standard Edition#java.lang|java.lang]]
* [[Java Platform, Standard Edition#java.lang.reflect|java.lang.reflect]]
* [[Java programming language]]
* [[Java syntax]]