Boolean.TRUE == myBoolean vs. Boolean.TRUE.equals(myBoolean)

后端 未结 4 1324
执笔经年
执笔经年 2021-02-08 08:51

Is there ever a situation where using equals(Boolean) and == would return different results when dealing with Boolean objects?

<         


        
4条回答
  •  孤城傲影
    2021-02-08 09:27

    == only works for primitive types
    when you compare Objects you should always use o.equls(Object ob)

提交回复
热议问题