compare() Method in java Addition of Integer with Float

Java Programming Language Number Class in java (Article) Number Class in java (Program)

958

Program:

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

        Integer intObj1 = new Integer (25);

        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));

        //Addition of Integer with Float
        Float f = intObj1.floatValue() + f1;
        System.out.println("Addition of intObj1 and f1: "+ intObj1 +"+" +f1+"=" +f );
    }

}

Output:

Comparing using compare f1 and f2: -1
Comparing using compare f1 and f3: 0
Addition of intObj1 and f1: 25+2.25=27.25
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.