Convert Double to numeric primitive data types in Java
Description
The following code shows how to convert Double to numeric primitive data types.
Example
//from w w w. j a v a2 s . c o m
public class Main {
public static void main(String[] args) {
Double dObj = new Double("10.50");
byte b = dObj.byteValue();
System.out.println(b);
short s = dObj.shortValue();
System.out.println(s);
int i = dObj.intValue();
System.out.println(i);
float f = dObj.floatValue();
System.out.println(f);
double d = dObj.doubleValue();
System.out.println(d);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »