Convert Wrapper Class to Data Types

What is Wrapper Class in Java Program?

Integer, String, Double, Short, Long, Float etc are wrapper class in java programs. These classes have many important methods which are using in programming.

Like convert String class value to int data types. In this step will use parseInt(StringValue) method. And this method is belongs to Integer Class.

Let’s see simple example and videos on our topic.

 

class wrapper1

{

                public static void main(String args[])

                {

                                int x;      // Simple Data Types

                                // Want to add value using command prompt

                                x = Integer.parseInt(args[0]);     // args[0] is wrapper class object

                                // x is simple data types

                                // How to store int value ??

                                // Step 1: Convert into Integer Wrapper Class

                                // Step 2 : Store value in normal data Types

 

                                System.out.println(“X = ” + x);

                }

}

Output:

If user adds 10 in comment prompt then

X = 10

 

Video available on YouTube.


If you have any query on blog example, you can directly comment us or subscribe our website


Earn Money Online

1445total visits,2visits today


mayank

Hello, I am Maddy a Java blogger, trainer and developer

Related articles

5 responses to “Convert Wrapper Class to Data Types”

  1. Attractive component to content. I simply stumbled upon your blog and in accession capital to assert that I acquire in fact loved account your blog posts. Any way I’ll be subscribing for your feeds and even I fulfillment you get entry to persistently rapidly.

  2. Hmm it looks like your blog ate my first comment (it was super long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog. I too am an aspiring blog writer but I’m still new to the whole thing. Do you have any tips and hints for inexperienced blog writers? I’d certainly appreciate it.|

  3. I just want to tell you that I’m very new to blogs and certainly savored you’re web site. Most likely I’m want to bookmark your website . You amazingly come with fabulous articles and reviews. Appreciate it for sharing with us your website.