문제

Is it compulsory to override the methods equals() and hashCode() for final classes?

Note : as all Wrapper classes are final and immutable and overrides the equals and hashCode methods.

Thanks in advance

도움이 되었습니까?

해결책

is it compulsary to override equals and hashCode methods for classes which are defined as final?

Define a class as final and overriding equals() and hashCode() are two different things.

Final is there to restrict a class not to be sub classed. And, equals() is there to check the equality of the instances of a class.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top