How to convert Short to numeric primitive data types in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        Short sObj = new Short("33");

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

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

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

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

        double d = sObj.doubleValue();
        System.out.println(d);

        long l = sObj.longValue();
        System.out.println(l);
    }
}
   
/*
      
run:
      
33
33
33
33.0
33.0
33
  
*/

 



answered Nov 7, 2016 by avibootz

Related questions

1 answer 244 views
1 answer 220 views
1 answer 228 views
1 answer 232 views
1 answer 205 views
...