Content deleted Content added
No edit summary |
Sammi Brie (talk | contribs) Adding intentionally blank description, overriding Wikidata description "computer term referring to a Java class in object-oriented programming" |
||
(16 intermediate revisions by 15 users not shown) | |||
Line 1:
{{Short description|none}}
In [[object
Primitive wrapper classes are used to create an {{Javadoc:SE|java/lang|Object}} that needs to represent primitive types in {{Javadoc:SE|java/util|Collection}} classes (i.e., in the Java API), in the {{Javadoc:SE|package=java.util|java/util}} package and in the {{Javadoc:SE|package=java.lang.reflect|java/lang/reflect}} [[Reflection (computer science)|reflection]] package. Collection classes are Java API
The primitive wrapper classes and their corresponding primitive types are:
Line 24 ⟶ 25:
| <code>boolean</code> || {{Javadoc:SE|java/lang|Boolean}} || <code>boolean</code> or <code>String</code>
|}
==The difference between wrapper classes and primitive types==
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
Therefore, the term ''Primitive wrapper class'' does not mean that wrapper classes are primitive types. It should be understood to be a class that wraps primitive types. 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 ''Non-Primitive''. We cannot say that Wrapper classes themselves are Primitive types. They just wrap 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 [[subclass (computer science)|subclass]]es of the {{Javadoc:SE|java/lang|Number}} class.
The wrapper classes <code>BigDecimal</code> and <code>BigInteger
| url = http://www.javaranch.com/journal/2003/04/immutable.htm
| title = Mutable and Immutable Objects: Which classes are Immutable?
| author = David O'Meara
| date = April 2003
| publisher = Java Ranch
| accessdate = 2012-05-14
Line 51 ⟶ 49:
| quote = Immutable arbitrary-precision integers.
}}</ref>
== Atomic wrapper classes ==
Line 77 ⟶ 69:
The <code>AtomicInteger</code> and <code>AtomicLong</code> classes are subclasses of the <code>Number</code> class. The <code>AtomicReference</code> class accepts the [[TypeParameter|type parameter]] <code>V</code> that specifies the type of the object [[reference (computer science)|reference]]. (See "[[Generics in Java]]" for a description of type parameters in Java).
== See also ==
|