当前位置:网站首页>Differences between comparable and comparator
Differences between comparable and comparator
2022-06-30 02:57:00 【Ppdy bud】
List of articles
The same thing
Are used to compare objects
Difference
1、Comparable: stay java.lang It's a bag
Comparator: stay java.util It's a bag
2、Comparable: Need to rewrite compareTo(Object o) Method
Comparator: Need to rewrite compare(Object o1, Object o2) Method
3、comparable:① It's an internal comparator , Objects of this class can be directly compared with each other this.compareTo(this),② You can use it directly Collections.sort Methods the sorting
Comparator:① It's an external comparator , It didn't come true comparable You can also compare and sort compare(o1,o2)
4、omparator It is a typical strategy pattern
5、Comparable and Comparator There is ,Comparator High priority
6、Comparable: You need to modify the original entity class , It's a natural sort
Comparator: A comparator implemented without modifying the original class , Widely used in practice
边栏推荐
- 浅谈IDEA的优化和使用
- 重磅来袭--UE5的开源数字孪生解决方案
- Mysql提取表字段中的字符串
- CMake教程系列-02-使用cmake代碼生成二進制
- Xunwei enzhipu ITop - imx6 Development Platform
- Redis+AOP怎么自定义注解实现限流
- 多卡服务器使用
- How do I enable assembly binding logging- How can I enable Assembly binding logging?
- CMake教程系列-04-编译相关函数
- Jvxetable sub table record loading completion event
猜你喜欢

Five cheapest wildcard SSL certificate brands

Raki's notes on reading paper: discontinuous named entity recognition as maximum clique discovery

High paid programmers & interview questions series 63: talk about the differences between sleep (), yield (), join (), and wait ()

oracle怎么设置密码复杂度及超时退出的功能

Pytoch learning (II)

Welfare lottery | what are the highlights of open source enterprise monitoring zabbix6.0

发现mariadb数据库时间晚了12个小时

Implementation of Sanzi chess with C language
![[Postgres] Postgres database migration](/img/45/7074aa766640160a3b6f00b109cb2f.png)
[Postgres] Postgres database migration

Software testing skills, JMeter stress testing tutorial, transaction controller of logic controller (25)
随机推荐
Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing
Wechat applet +php to realize authorized login operation
Global and Chinese market of ERP software for garment and textile industries 2022-2028: Research Report on technology, participants, trends, market size and share
JMeter obtains cookies across thread groups or JMeter thread groups share cookies
Linear algebra Chapter 3 summary of vector and vector space knowledge points (Jeff's self perception)
快速排序、聚簇索引、尋找數據中第k大的值
Mysql表数据比较大情况下怎么修改添加字段
Mysql提取表字段中的字符串
Linear algebra Chapter 4 Summary of knowledge points of linear equations (Jeff's self perception)
Global and Chinese market of mobile commerce solutions 2022-2028: Research Report on technology, participants, trends, market size and share
New edition of diazotization process in 2022 and analysis of diazotization process
Raki's notes on reading paper: named entity recognition as dependency parsing
What is the concept of string in PHP
The rigorous judgment of ID number is accurate to the last place in the team
HTA introductory basic tutorial | GUI interface of vbs script HTA concise tutorial, with complete course and interface beautification
Servlet面试题
Cmake tutorial series -02- generating binaries using cmake code
O & M (20) make and start USB flash disk and install win10
Precautions for purchasing wildcard SSL certificate
RAII内存管理