0% found this document useful (0 votes)
20 views

Wrapper Class in Java

Uploaded by

akmajith1998
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Wrapper Class in Java

Uploaded by

akmajith1998
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Gayatri Mishra | https://www.linkedin.

com/in/gayatri-mishra-freelancecoach/

Gayatri Mishra | https://www.linkedin.com/in/gayatri-mishra-freelancecoach/

A short into to Wrapper class in java with example :

Java Wrapper classes wrap the primitive data types, that is why it is known as wrapper classes.

Wrapper classes we commonly use :

 Integer
 Double
 Float

These classes are very much useful in converting data like converting string to any primitive data type int ,
double , float ect.

How can we use wrapper class ?

String s = “49600.90”;

Let’s say we need to convert the string into decimal to perform further operations.

We can follow below steps.


Step-1:
1. Initialize the string or get the dynamically and store the same in string variable using getText()
method.
String s1=”496000.90”
2. Declare the double variable.
double amount;
3. Convert the string to double:
amount = Double.ParseDouble(s1); // pass the string as parameter
4. Print the amount.
System.out.println(“The amount of the item is “ + amount);

Note : Please check the below sample code


Gayatri Mishra | https://www.linkedin.com/in/gayatri-mishra-freelancecoach/

You might also like