Why are two AtomicIntegers never equal?

前端 未结 9 2155
日久生厌
日久生厌 2020-12-01 18:02

I stumbled across the source of AtomicInteger and realized that

new AtomicInteger(0).equals(new AtomicInteger(0))

evaluates to

9条回答
  •  醉话见心
    2020-12-01 18:26

    Imagine if equals was overriden and you put it in a HashMap and then you change the value. Bad things will happen:)

提交回复
热议问题