TreeSet排序
来源:互联网 发布:js字符串反转 编辑:程序博客网 时间:2024/06/16 02:22
import java.util.*;
public class TestTreeSet
{
public static void main(String[] args){
//Comparator的实现类型是TreeSet里实际类型的父类,满足要求
TreeSet<String> ts1=new TreeSet<String>(new Comparator<Object>(){
public int compare(Object fst,Object snd){
return fst.hashCode()-snd.hashCode();
}
}
);
ts1.add("a");
ts1.add("b");
TreeSet<String> ts2=new TreeSet<String>(
new Comparator<String>(){
public int compare(String fst,String snd){
return -(fst.length()-snd.length());
}
}
);
ts2.add("a");
ts2.add("cx");
System.out.println(ts1);
System.out.println(ts2);
String a="a";
String b="b";
System.out.println(a.hashCode());
System.out.println(b.hashCode());
}
}
- TreeSet排序
- TreeSet 排序
- TreeSet排序
- TreeSet 排序
- 使用TreeSet()进行排序
- 总结TreeSet排序问题
- TreeSet进行中文排序
- TreeSet排序总结
- TreeSet实现排序(二)
- TreeSet实现排序(一)
- TreeSet排序问题
- 总结TreeSet排序问题
- TreeSet自然排序
- TreeSet的排序
- TreeSet实现自定义排序
- 总结TreeSet排序问题 .
- TreeSet排序树
- TreeSet排序Comparator
- GATEWAY获取与设置(Linux C)
- CUDA 存储器种类分析及使用方法指南
- Linux文件查找命令find,xargs详述
- ArcGIS10.0操作之五——Spital Analyst和3D Analyst工具条的变化
- Android中ScrollView用法介绍
- TreeSet排序
- WIN_静态库与动态库的加载
- 天下大道
- java5线程并发库
- 为什么static数据成员必须在类外初始化
- 设计模式学习-Bridge(桥接)
- 性能分析方法
- 关于登陆脚本的 troubleshooting
- Android常用的简单代码