Java中==和equals()有什麼區別? - What is the difference between == and equals() in Java?

問題:

I wanted to clarify if I understand this correctly: 我想澄清一下我是否正確理解了這一點: this

  • == is a reference comparison, ie both objects point to the same memory location ==是參考比較,即兩個對象都指向相同的存儲位置
  • .equals() evaluates to the comparison of values in the objects .equals()計算對象中值的比較

解決方案:

參考一: https://stackoom.com/question/VYPI/Java中-和equals-有什麼區別
參考二: https://oldbug.net/q/VYPI/What-is-the-difference-between-and-equals-in-Java
相關文章
相關標籤/搜索