Float.compareTo(Float anotherFloat) has the following syntax.
public int compareTo(Float anotherFloat)
In the following code shows how to use Float.compareTo(Float anotherFloat) method.
The following code illustrates how to create NaN
in float and compares to another float
type value.
public class Main { public static void main(String[] args) { Float floatObject1 = new Float("10.0001"); //from ww w . ja va 2 s.c o m Float floatObject2 = Float.valueOf((float)0.0/(float)(0.0)); System.out.println(floatObject2); System.out.println(floatObject1.compareTo(floatObject2)); } }
The output: