Create Float Objects in Java
Description
The following code shows how to create Float Objects.
Example
/*from w ww . j a v a2 s. co m*/
public class Main {
public static void main(String[] args) {
float f = 10.10f;
Float fObj1 = new Float(f);
System.out.println(fObj1);
double d = 10.10;
Float fObj2 = new Float(d);
System.out.println(fObj2);
Float fObj3 = new Float("25.34");
System.out.println(fObj3);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »