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...

What are wrapped classes?

Answer Posted / rama krishna dwadasi

There are 8 wrapper classes which are equivalent to 8
primitive data types.

Primitive type Wrapper Class
1. byte Byte
2. short Short
3. int Integer
4. long Long
5. float Float
6. double Double
7. char Character
8. boolean Boolean

Wrapper classes are useful in the following ways:-
1. Wrapper classes are used to convert one data type to
another data type. For example:- converting int to double,
double to float, float to String, String to float etc.
2. We can convert primitive to objects and objects to
primitive. For example:- In collections we cannot store
primitive values and we have to store only objects.

Note: All primitive types can be converted to String and
corresponding Wrapper objects.

Following are the general conversions we generally do.
1. primitive to wrapper. (int to Integer).
2. one primitive to another primitive type.(int to float).
3. primitive to String. (int to String).
4. wrapper to primitive.(Integer to int)
5. wrapper to String.(Integer to String)
6. String to primitive.(String to int)
7. String to wrapper.(String to Integer)

1Q: How to convert primitives to wrapper objects?
A: 1) By using the corresponding constructor.
2) By using valueOf(primitive type) method

//Program to convert primitive to wrapper object

// 1) By using constructor
//2) By using valueOf() method

// to convert to int to wrapper object
int i = 10;
Integer x = new Integer(i);
Integer p = Integer.valueOf(i);

//to convert double to wrapper object
double d = 99.99;
Double y = new Double(d);
Double q = Double.valueOf(d);

//to convert boolean to wrapper object
boolean b = true;
Boolean z = new Boolean(b);
Boolean r = Boolean.valueOf(b);

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is static block?

1058


Explain, java is compatible with all servers but not all browsers?

1004


What is the synonym of framework?

938


Write a program to print fibonacci series up to count 10.

851


What is the difference between variable declaration and variable initialization?

978


why using interface interface ?

1972


What is string and example?

980


How do you check if a character in a string is a digit or letter?

1009


Write a program to check string is palindrome without using loop?

981


Which api is provided by java for operations on set of objects?

1397


What is difference between == and === in js?

959


What is linked hashmap and its features?

970


What environment variables are required to be set on a machine in order to run Java programs?

1112


What happens if an exception is throws from an object's constructor?

1075


Is it possible to override private or static method in java?

939