equals() Method in java wrapper class Example 2

Java Programming Language / Number Class in java

1023

Program:

 public class WrapperequalsMethod {
    public static void main (String args[]){
        Integer intObj1 = new Integer (25);
        Integer intObj2 = new Integer ("25");
        Integer intObj3= new Integer (35);

     //Equals demo
        System.out.println("Comparing using equals Obj1 and Obj2: " + intObj1.equals(intObj2));
        System.out.println("Comparing using equals Obj1 and Obj3: " + intObj1.equals(intObj3));

    }

}

  

Output:

Comparing using equals Obj1 and Obj2: true
Comparing using equals Obj1 and Obj3: false
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.