Java long equals() method example

HQ » Java Tutorial » java.lang » Long » equals(Object obj)
Java long equals() method example 2018-02-16T07:26:14+00:00

java.lang.Long equals(Object obj)


The equals() java method compares this object to the specified object. The result is true if and only if the argument is not null and is a Long object that contains the same long value as this object.


  • This method is overrides equals in class Object

Method Syntax

public boolean equals(Object obj)

Method Argument

Data Type Parameter Description

Method Returns

The equals(Object obj) method of Long class returns true if the objects are the same; false otherwise.


Requires Java 1.0 and up

Java Long equals() Example

Below is a simple java example on the usage of equals() method of Long class.

Sample Output

Below is the sample output when you run the above example.

Java Long equals(Object obj) example output

Contact Info


Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.