If a number has a decimal it is a double. To make such a number a float you can do
float f = (float)3.14; // cast
// or
float c = 3.14f; // or 3.14F
And any number of lesser precision can be assigned to a reference of higher precision.
float f = 25;
double d = 15f;
long b = 88; // int
To see what java says:
class FloatTest {
public static void main(String[] args) {
check(-343);
check(3.14);
check(0x12345);
check(42e7);
check(2001.0D);
check(2.81F);
}
private static void check(Number n) {
System.out.println(n + " = " + n.getClass().getName());
}
}