How to convert Integer to numeric primitive data types in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        Integer intObj = new Integer("120");

        byte b = intObj.byteValue();
        System.out.println(b);

        short s = intObj.shortValue();
        System.out.println(s);

        int i = intObj.intValue();
        System.out.println(i);

        float f = intObj.floatValue();
        System.out.println(f);

        double d = intObj.doubleValue();
        System.out.println(d);
    }
}
   
/*
      
run:
      
120
120
120
120.0
120.0
  
*/

 



answered Nov 6, 2016 by avibootz

Related questions

1 answer 285 views
1 answer 219 views
1 answer 227 views
1 answer 231 views
1 answer 204 views
...