compare() Method in java

Java Programming Language / Number Class in java

1064

Program:

 public class WrappercompareMethod {
    public static void main (String args[]){

        Float f1 = new Float("2.25f");
        Float f2 = new Float("20.43f");
        Float f3 = new Float(2.25f);

        System.out.println("Comparing using compare f1 and f2: " +Float.compare(f1,f2));
        System.out.println("Comparing using compare f1 and f3: " +Float.compare(f1,f3));

    }

}

Output:

Comparing using compare f1 and f2: -1
Comparing using compare f1 and f3: 0
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.