Why Java does not see that Integers are equal?

后端 未结 6 1812
野的像风
野的像风 2020-11-29 06:51

I have integers that are supposed to be equal (and I verify it by output). But in my if condition Java does not see these variables to have the same value.

6条回答
  •  半阙折子戏
    2020-11-29 07:12

    If they were simple int types, it would work.

    For Integer use .intValue() or compareTo(Object other) or equals(Object other) in your comparison.

提交回复
热议问题