当前位置:网站首页>Comparator summary
Comparator summary
2022-06-12 13:45:00 【Disobey the law】
Comparator summary
1. Internal comparator
public class ClassName implements Comparable<Object>{
public ClassName{
}
public int compareTo(Object o){
return this.-o.;// Ascending
}
}
Collections.sort(array);
2. External comparator
public class MyComparator implements Comparator<Object>{
public int compare(Object first,Object second){
return first.-second.;// Ascending
//String Type is used (first.).compareTo(second.)
}
}
Collections.sort(array,new MyComparator());
3. Anonymous inner class
Collections.sort(array,new Comparator<Object>{
public int compare(Object first,Object second){
return first.-second.;
}
});
4.Lambda
Collections.sort(array,(first,second)->{
return frist.-second.
});
边栏推荐
- A method of quickly creating test window
- Octopus network progress monthly report | may 1-May 31, 2022
- Application of list and Dict
- Paw advanced user guide
- Codeforces 1629 F2. Game on sum (hard version) - Yang Hui's triangle, violence, finding rules
- Codeforces 1638 A. reverse - simple thinking
- 基于华为云鲲鹏弹性云服务器ECS部署openGauss数据库【这次高斯不是数学家】
- [brush title] probability of winning a draw
- 高通平台开发系列讲解(协议篇)QMI简单介绍及使用方法
- Script import CDN link prompt net:: err_ FILE_ NOT_ Found problem
猜你喜欢

C#DBHelper_ FactoryDB_ GetConn

torch_ geometric message passing network

Innovation training (XI) summary of some bugs in the development process

leetcode 47. Permutations II full permutations II (medium)

简历 NFT 平台 TrustRecruit 加入章鱼网络成为候选应用链

编译安装基于fastcgi模式的多虚拟主机的wordpress和discuz的LAMP架构

Script引入CDN链接提示net::ERR_FILE_NOT_FOUND问题

VGA display color bar and picture (FPGA)

Successfully rated Tencent t3-2, 10000 word parsing

Pytorch framework
随机推荐
Codeforces 1634 F. Fibonacci additions - Fibonacci sequence addition, ideas
Realization of Joseph Ring with one-way ring linked list
C#DBHelper_ FactoryDB_ GetConn
JSP jump problem, unable to display database data, and unable to jump
1005: estimation of the earth's population carrying capacity
Return value of WaitForSingleObject
Explanation of static and extern keywords
Codeforces 1637 D. yet another minimization problem - Mathematics, DP
VGA display color bar and picture (FPGA)
m1 pod install pod lint 失败解决方案
Innovation training (x) advanced interface beautification
Formal analysis of Woo Lam protocol with scyther tool
一种快速创建测试窗口的方法
import torch_ Geometric loads some common datasets
C language structure
Xcode debugging OpenGLES
Encryptor and client authenticate with each other
Getting started with NVIDIA Jetson nano Developer Kit
播放器屏幕方向方案
C language [23] classic interview questions [2]