java.lang.Float.compareTo()


java.lang.Float.compareTo()

package com.codingdict;



import java.lang.*;



public class FloatDemo {



   public static void main(String[] args) {



      // compares two Float objects numerically

      Float obj1 = new Float("10.2");

      Float obj2 = new Float("10.20");

      int retval =  obj1.compareTo(obj2);



      if(retval > 0) {

         System.out.println("obj1 is greater than obj2");

      } else if(retval < 0) {

         System.out.println("obj1 is less than obj2");

      } else {

         System.out.println("obj1 is equal to obj2");

      }

   }

}