what are wrapper classes

Primitive wrapper class - Wikipedia, the free encyclopedia


** Primitive wrapper class **

From Wikipedia, the free encyclopedia
Jump to: navigation, search

This article's *tone or style may not reflect the encyclopedic tone used
on Wikipedia*. See Wikipedia's guide to writing better articles for
suggestions. /(November 2014)/

A *primitive - wrapper class* in the Java and ActionScript programming
languages is one of eight classes provided in the java.lang package to
provide object methods for the eight primitive types. All of the primitive
wrapper classes in Java are 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.

Wrapper classes are used to represent primitive values when an Object is
required. The wrapper classes are used extensively with Collection classes
in the java.util package and with the classes in the java.lang.reflect
reflection package.

The primitive wrapper classes and their corresponding primitive types are:

Primitive type Wrapper class Constructor Arguments
byte Byte byte or String
short Short short or String
int Integer int or String
long Long long or String
float Float float, double or String
double Double double or String
char Character char
boolean Boolean boolean or String

*Don't get confused*
The term mentioned /Primitive Wrapper Classes/ *does not really* 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 /Non-Primitive/. We cannot say that Wrapper
classes themselves are Primitive types. They just wrap the primitive types.

The Byte, Short, Integer, Long, Float, and Double wrapper classes

Source: en.wikipedia.org/wiki/Primitive_wrapper_class

© 2005-2019 HaveYourSay.org