What is a Wrapper class?

Answer Posted / sandeep sagala

A primitive wrapper class in the Java programming language
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 auto boxing 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

The Byte, Short, Integer, Long, Float, and Double wrapper
classes are all subclasses of the Number class.This Number
class is subject to the object class

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What about interrupt() method of thread class ?

855


What is internal iteration in java se 8?

876


How to implement an arraylist in java?

725


Difference between predicate, supplier and consumer ?

818


What are benefits of java?

818


Where is jre installed?

806


Explain constructors and types of constructors in java.

844


When does an object becomes eligible for garbage collection in java?

825


How does callback work in java?

820


What are thread groups?

771


Can a constructor be protected?

806


How can we find the sum of two linked lists using stack in java?

789


what is meant by HQL?

851


Why do we need hashset in java?

741


What is the buffer limit?

770