Java Integer.equals(Object obj)

Syntax

Integer.equals(Object obj) has the following syntax.

public boolean equals(Object obj)

Example

In the following code shows how to use Integer.equals(Object obj) method.


public class Main {
//from w  w w. j av a2s.  c  o  m
   public static void main(String[] args) {

     Integer obj1 = new Integer(5);
     Integer obj2 = new Integer(5);
     System.out.println(obj1.equals(obj2));
    
     obj1 = new Integer(3);
     obj2 = new Integer(2);
     System.out.println(obj1.equals(obj2));
   }
} 

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable