Click here to Skip to main content
15,905,612 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why we need wrapper class?
What we are achieving wrapper class?
How to create Wrapper class?and Give some example of this?
Properties of Wrapper class?
Posted

Wrapper class in nothing but the object of your primitive data types i.e int, double, float etc.
However, in development, we come across situations where we need to use objects instead of primitive data types. In-order to achieve this Java provides wrapper classes for each primitive data type. i.e Socket or Remote Programming

Refer this:
http://way2java.com/java-lang/wrapper-classes/[^]
http://stackoverflow.com/questions/3579035/why-are-there-wrapper-classes-in-java[^]
http://www.tutorialspoint.com/java/java_numbers.htm[^]

-KR
 
Share this answer
 
Wrapper classes allow primitive data types to be accessed as objects. They are one per primitive type: Boolean, Byte, Character, Double, Float, Integer, Long and Short. Wrapper classes make the primitive type data to act as objects.

why we can use?
Dealing with primitives as objects is easier at times. Most of the objects collection store objects and not primitive types. Many utility methods are provided by wrapper classes. To get these advantages we need to use wrapper classes. As they are objects, they can be stored in any of the collection and pass this collection as parameters to the methods.
Features of the Java wrapper Classes.

-Wrapper classes convert numeric strings into numeric values.
-The way to store primitive data in an object.
-The valueOf() method is available in all wrapper classes except Character
-All wrapper classes have typeValue() method. This method returns the value of the object as its primitive type.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900