Why Java does not see that Integers are equal?

后端 未结 6 1810
野的像风
野的像风 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:16

    There are two types to distinguish here:

    • int, the primitive integer type which you use most of the time, but is not an object type
    • Integer, an object wrapper around an int which can be used to use integers in APIs that require objects

提交回复
热议问题