Compare Float

 
public class Main {

  public static void main(String[] args) {
    float f1 = 5.5f;
    float f2 = 5.4f;
    int i1 = Float.compare(f1, f2);
    if (i1 > 0) {
      System.out.println(">");
    } else if (i1 < 0) {
      System.out.println("<");
    } else {
      System.out.println("=");
    }

    Float fObj1 = new Float("5.5");
    Float fObj2 = new Float("5.4");
    int i2 = fObj1.compareTo(fObj2);
    if (i2 > 0) {
      System.out.println(">");
    } else if (i2 < 0) {
      System.out.println("<");
    } else {
      System.out.println("=");
    }
  }
}
  
Home 
  Java Book 
    Runnable examples  

Data Type Float:
  1. Cast a float or double to an integral value
  2. Create Float from float value
  3. Compare Float
  4. Convert float to string
  5. Convert Float to Numeric Primitive Data Types
  6. Is Float infinite
  7. Is Float Not a Number(isNaN)
  8. Min and Max value of float type