Primitive wrapper class in Java: Difference between revisions

Content deleted Content added
No edit summary
Gprathour (talk | contribs)
Hello ! Readers especially students might get confused after reading the word "Primitive Wrapper classes" It seems like we mean to say that wrapper classes are primitive types in Java. I am a Java Professional, so I wanted to clear this doubt. Thanks.
Line 1:
A '''primitive - wrapper class''' in the [[Java (programming language)|Java]] and [[ActionScript]] programming languages 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]]. [[Java Platform, Standard Edition|J2SE]] 5.0 introduced [[Boxing (computer_science)#Autoboxing|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 to 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.
Line 24:
| <code>boolean</code> || {{Javadoc:SE|java/lang|Boolean}} || <code>boolean</code> or <code>String</code>
|}
 
<b>Don't get confused</b><br/>
The term mentioned Primitive Wrapper Classes <b>does not</b> mean that Wrapper classes are Primitive types in Java. It should be read this way, a class that wraps a primitive type. Wrapper classes can be used to store the same value as of a primitive type variable but the instances/objects of wrapper classes themselves are <i>Non-Primitive</i>. We cannot say that Wrapper classes themselves are Primitive types. They just wraps the primitive types.
 
 
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.