image.png
報(bào)此異常
是因?yàn)橐砑拥膶ο笮枰獙?shí)現(xiàn) comparable接口
image.png
并且重寫comparato方法
image.png
但是往Hashset方法里添加對象元素就不需要實(shí)現(xiàn)comparable接口,就可以直接添加對象.因?yàn)?/p>
image.png
報(bào)此異常
是因?yàn)橐砑拥膶ο笮枰獙?shí)現(xiàn) comparable接口
并且重寫comparato方法
但是往Hashset方法里添加對象元素就不需要實(shí)現(xiàn)comparable接口,就可以直接添加對象.因?yàn)?/p>