---
title: "Discussion on \"Equality of Integer and Long objects in Java\" | Hashnode"
description: "Discussion on \"Equality of Integer and Long objects in Java\". TLDR\nUse the equals method when checking if Integer or Long objects are equal.\nInteger a = 1000;\nInteger b = 1000;\n\na.equals(b); // true\na == b; // false\n\nUsing == sometimes returns incorrect results\nChecking the equality of Integer objects with the ..."
url: "https://hashnode.com/posts/equality-of-integer-and-long-objects-in-java/610683d53b9b85399dcf468a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Equality of Integer and Long objects in Java](https://genakag.hashnode.dev/equality-of-integer-and-long-objects-in-java?utm_source=hashnode&utm_medium=feed)

TLDR Use the equals method when checking if Integer or Long objects are equal. Integer a = 1000; Integer b = 1000; a.equals(b); // true a == b; // false Using == sometimes returns incorrect results Checking the equality of Integer objects with the ...

Aug 1, 2021 · 2 min read · genakag.hashnode.dev  
Updated Aug 4, 2021  
Read the article

-   [#java](https://hashnode.com/tag/java)

## Written by

[Gene Nakagaki](https://hashnode.com/@genakag)

@genakag · Tokyo, Japan

  
[View profile](https://hashnode.com/@genakag)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
