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