Wrapper Class - Converting numeric string object to primitive numbers in Java


A Wrapper class is a class whose object wraps or contains primitive data types. When we create an object to a wrapper class, it contains a field and in this field, we can store primitive data types. In other words, we can wrap a primitive value into a wrapper class object.

Source Code

public class wrapperClass5 {
    public static void main(String args[])
    {
        //Converting numeric string object to primitive numbers.
        /*String SI="25";
        Integer I= Integer.valueOf(SI);
        int i= I.intValue();
        System.out.println(i);*/
 
        String SI="25";
        int i=Integer.parseInt(SI);
        System.out.println("int Value : "+i);
        String SF="25.25f";
        float f=Float.parseFloat(SF);
        System.out.println("float Value : "+f);
    }
}
 

Output

int Value : 25
float Value : 25.25
To download raw file Click Here

Basic Programs