Online Java Compiler By
JavaTpoint.com
import java.lang.Float; public class FloatcompareMethodExample1 { public static void main(String[] args) { Float f1 = new Float("10"); Float f2 = new Float("50.44"); // comparing f1 and f2 int compare=Float.compare(f1 , f2); if(compare > 0){ System.out.println(f1+" is greater and "+f2+" is smaller."); } else if(compare<0){ System.out.println(f1+" is smaller "+f2+" is greater."); } else{ System.out.println(" Both are equal! "); } } }
Output