How to convert Long to numeric primitive data types in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
  
        Long l = new Long(30);

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

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

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

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

        double d = l.doubleValue();
        System.out.println(d);
    }
}
 
/*
    
run:
    
30
30
30
30.0
30.0

*/

 



answered Nov 3, 2016 by avibootz

Related questions

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