사용자 도구

사이트 도구


java:equals_hashcode

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
java:equals_hashcode [2017/07/04 00:59]
kwon37xi [동치(equivalence)를 위반해서는 안된다]
java:equals_hashcode [2017/07/04 01:02]
kwon37xi [동치 문제의 최종 해결책 canEqual]
줄 1: 줄 1:
 ====== Java equals & hashCode ====== ====== Java equals & hashCode ======
-  * [[java:equals_verifier|Equals Verifier]]+  * [[java:equals_verifier|Equals Verifier]] ''equals'', ''hashCode'' 테스트 자동화
   * [[java:hibernate:equalsandhashcode|Hibernate and equals & hashCode]]   * [[java:hibernate:equalsandhashcode|Hibernate and equals & hashCode]]
  
줄 59: 줄 59:
     if (other instanceof Point) {     if (other instanceof Point) {
         Point that = (Point) other;         Point that = (Point) other;
-        // that.canEqual(this) 가 핵심이다. 이를 거꾸로 면 안된다.+        // that.canEqual(this) 가 핵심이다. 이를 거꾸로 this.canEqual(that) 으로 사용하면 안된다.
         result = (that.canEqual(this) && this.getX() == that.getX() && this.getY() == that.getY());         result = (that.canEqual(this) && this.getX() == that.getX() && this.getY() == that.getY());
     }     }
java/equals_hashcode.txt · 마지막으로 수정됨: 2017/07/04 01:06 저자 kwon37xi