Comparing two objects, either of which could be null

后端 未结 4 1584
攒了一身酷
攒了一身酷 2021-01-04 19:06

I have a function in one of my classes that compares itself with another instance of the same class - and finds out which variables differ. This is for the purpose of minimi

4条回答
  •  粉色の甜心
    2021-01-04 19:47

    You can use Apache object utils

    ObjectUtils.equals(Object object1, Object object2) -- Returns boolean

    this method has been replaced by java.util.Objects.equals(Object, Object) in Java 7

提交回复
热议问题