Convert string object to primitive Integer Type

How can i convert a string object to a primitive Integer type???????

Thanks

Questions by tapan_1984   answers by tapan_1984

Showing Answers 1 - 21 of 21 Answers

sampra

  • Feb 20th, 2008
 

class Test
{
 public static void main(String as[])
 {
    String s="22";
    Integer i=new Integer(s);
    int a=i.intValue();
    System.out.println(a);   
 }
}

maddy_me

  • Sep 18th, 2009
 

class StringConver
{
 public static void main(String[] s)
 {
     //String s1 = "Hello"; If you try this you will get NumberFormatException
        String s1 = "12345";
        Integer i = Integer.parseInt(s1);
        System.out.println(i);
 }
}

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions