Floating-point literals in Java default to double precision. To specify a float literal, you must append an F or f to the constant.
public class Main {
public static void main(String args[]) {
float d = 3.14159F;
System.out.print(d);//3.14159
}
}
Java's floating-point calculations are capable of returning +infinity, -infinity, +0.0, -0.0, and NaN
public class Main {
public static void main(String[] args) {
Float f1 = new Float(Float.NaN);
System.out.println(f1.floatValue());
Float f2 = new Float(Float.NaN);
System.out.println(f2.floatValue());
System.out.println(f1.equals(f2));
System.out.println(Float.NaN == Float.NaN);
System.out.println();
}
}