Primitive wrapper class in Java: Difference between revisions

Content deleted Content added
No edit summary
Line 6:
 
:{| class="wikitable"
! Primitive type !! Wrapper class !! Constructor Argumentsarguments
|-
| <code>byte</code> || {{Javadoc:SE|java/lang|Byte}} || <code>byte</code> or <code>String </code>
Line 27:
<div style="text-align:justify;">
 
==The Differencedifference between Wrapperwrapper Classesclasses and Primitiveprimitive Typestypes==
 
Primitive wrapper classes are not the same thing as primitive types. Whereas variables, for example, can be declared in Java as data types '''double''', '''short''', '''int''', etc., the primitive wrapper classes create instantiated objects and methods that inherit but hide the primitive data types, not like variables that are assigned the data type values.<ref>J. Murach, ''Murach's Java Programming'', 4th Edition, Mike Murach and Associates, Inc., 2011.</ref>
Line 52:
}}</ref>
 
==The Wrapperwrapper Classclass Voidvoid==
 
The wrapper class named '''Voidvoid''' is not a primitive wrapper class, specifically because '''void''' is not a primitive data type. However the '''Voidvoid''' wrapper class can be used to create new objects that have methods that are not expected to return a value.
 
Although it is a wrapper class, the {{Javadoc:SE|java/lang|Void}} class provides an object representation of the [[void type|<code>void</code>]] return.