Difference between Equals/equals and == operator?

前端 未结 11 951
一生所求
一生所求 2020-11-22 14:14

What is the difference between a == b and a.Equals(b)?

11条回答
  •  遥遥无期
    2020-11-22 14:55

    == uses the reference of an object, or if an integer/float etc, then it compares the actual number. Technically it just compares what in the memory location. Whereas .equals uses a method inside the object class to compare objects, it can be overridden for your individual classes. Also as arrays also deal with references, its also helpful not to use array1[i] = array2[i], use arraycopy or clone(). I think .equals can also be used with arrays

提交回复
热议问题