Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


please tell me what is wrapper class in java with example ?

Answers were Sorted based on User's Feedback



please tell me what is wrapper class in java with example ?..

Answer / vikneswarank

its a class used to convert primitive data type to user
defined data type like Integer

for example

public class WrapperSample1
{
public static void main (String args[])
{
int iVal = 100;
long lVal = 200;
float fVal = 300;
double dVal = 400;

String str = "123";

//primitive types to corresponding wrapper objects
Integer intVal = Integer.valueOf(iVal);
Long lgVal = Long.valueOf(lVal);
Double dbVal = Double.valueOf(dVal);
Float ftVal = Float.valueOf(fVal);

//primitive types to string objects
str = String.valueOf(iVal);
str = String.valueOf(lVal);
str = String.valueOf(fVal);
str = String.valueOf(dVal);

//wrapper Objects to corresponding primitive types
iVal = intVal.intValue();
lVal = lgVal.longValue();
fVal = ftVal.floatValue();
dVal = dbVal.doubleValue();

//String to primitive types
iVal = Integer.parseInt(str);
lVal = Long.parseLong(str);
fVal = Float.parseFloat(str);
dVal = Double.parseDouble(str);

//string to wrapper objects
intVal = Integer.valueOf(str);
lgVal = Long.valueOf(str);
ftVal = Float.valueOf(str);
dbVal = Double.valueOf(str);
}
}

Is This Answer Correct ?    60 Yes 17 No

please tell me what is wrapper class in java with example ?..

Answer / naresh tuhania

By the help of Wrapper classes we can convert a primitive
type into Object type . These are the static classes and
provides methods for this .

Is This Answer Correct ?    41 Yes 7 No

please tell me what is wrapper class in java with example ?..

Answer / srinu

The wrapper class used for To convert Primitive data Type
in to User defined data Type and also Collection class
contain all user defined data type this user defined data
type convert into primitive data type

Is This Answer Correct ?    22 Yes 8 No

please tell me what is wrapper class in java with example ?..

Answer / pradeep

the wrapper class is used for accessing the primtive data
type for to the object.

Is This Answer Correct ?    16 Yes 3 No

please tell me what is wrapper class in java with example ?..

Answer / ankur tyagi

The wrapper class used for To convert Primitive data Type
in to User defined data Type.

Is This Answer Correct ?    7 Yes 0 No

please tell me what is wrapper class in java with example ?..

Answer / kotimuthyala

for each and every fundamental datatype theire exist predefined class.such predefined called wrapper class.the perpose of wrapper class is that converting numerical string data into fundamental data

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is an image buffer?

0 Answers  


what is the difference between Object Based Language and Object Oriented Language?

0 Answers   Aspire,


What is the hashcode () and equals () used for?

0 Answers  


What is thread safe in java?

0 Answers  


if num=687; U have to get num=6+8+7;

4 Answers   CMC,


What are selection structures?

0 Answers  


What is passed by reference and pass by value ?

0 Answers  


How do you create a sop?

0 Answers  


How do I start learning java?

0 Answers  


Is java hashset ordered?

0 Answers  


tell me some common

2 Answers   TCS,


Why deletion in linkedlist is fast than arraylist?

0 Answers  


Categories