comparison method
时间: 2023-09-24 07:09:38 浏览: 149
一个比较工具
comparison method 是用于比较两个对象的方法。引用中的例子是一个比较对象分数的方法,而引用中的例子是比较字符串长度的方法。然而,在引用中指出了一个问题,即传递性原则的违反。具体来说,如果存在三个元素stu1,null,stu2,那么比较stu1和null的结果为0,比较null和stu2的结果也为0,但是比较stu1和stu2的结果却为1,这违反了传递性原则。因此,编写比较方法时需要特别注意避免违反传递性原则。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Comparison method violates its general contract解决办法](https://blog.csdn.net/qq_22181793/article/details/126300295)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [“Comparison method violates its general contract!”问题原因及解决办法](https://blog.csdn.net/samur2/article/details/109231250)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文