Skip to content

[Item11] 좋은 hashCode를 작성하는 요령  #17

@IAGREEBUT

Description

@IAGREEBUT

좋은 hashCode를 작성하는 요령 중 (책 68-69p)
2.b에 대해서 예시를 들어서 설명 해주시면 좋을 것 같습니다

참조 타입 필드면서 이 클래스의 equals메서드가 이 필드의 equals를 재귀적으로 호출해 비교한다면,
이 필드의 hashCode를 재귀적으로 호출한다. 계산이 더 복잡해질 것 같으면,
이 필드의 표준형(ca-nonical representation)을 만들어 그 표준형의 hashCode를 호출한다.
필드의 값이 null이면, 0을 사용한다

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions