Java Data Type Tutorial - Java Long.equals(Object obj)








Syntax

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

public boolean equals(Object obj)

Example

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

If you just want to check the equality,

public class Main {
  public static void main(String[] args) {
    Long long1 = new Long(12345L);
    Long long2 = new Long("12346");
    
    System.out.println(long1.equals(long2));
  }
}

The output: