0

I can came across comparing AtomicInteger instances in my code and found no equals methods overridden. However java.lang.Integer does provide implementation for equals/hashCode methods.

The users shall take alternate route of comparing int from get() or getInt() methods.

My question is what stopped Sir. Doug Lea to not override equals/hashCode methods? I am sure there are valid reasons for it which I am not aware of.

wassgren
  • 18,651
  • 6
  • 63
  • 77
Maas
  • 1,317
  • 9
  • 20

1 Answers1

0

Objects of AtomicInteger are Mutable and its enough hint to not override hashcode and equals.

Its not advisable to use mutable objects as keys for Maps and hence no reason to override hashcode and hence equals.

Pandiri
  • 313
  • 1
  • 4