HashSet和TreeSet中最好只放入不可变对象
2015-11-05 15:25
225 查看
1234567891011121314151617181920212223242526272829303132333435363738394041 | class UN implements Comparable { private final int count; public UN() { this .count= 0 ; } public UN( int count) { this .count=count; } public int getCount() { return this .count; } public String toString() { return "R[count:" +count+ "]" ; } public boolean equals(Object obj) { if ( this ==obj) { return true ; } if (obj!= null &&obj.getClass()==UN. class ) { UN r=(UN)obj; if (r.count== this .count) { return true ; } } return false ; } public int compareTo(Object obj) { UN r=(UN)obj; return count>r.count? 1 :count<r.count? - 1 : 0 ; } } |
相关文章推荐
- POJ 1465 Multiple(用BFS求能组成的n的最小倍数)
- Android Resource概述
- 国密SKF接口函数介绍之一:设备管理函数
- 使用sqlload批量导入数据
- Windows Server 2008 R2与LoadRunner
- 获取全国市以及地理坐标,各大坐标系北斗,百度,WGS-84坐标系的转换,有图,有代码
- IIS服务器允许跨域配置
- 女子开跑车送外卖 半年从月入1500变15万
- linux下进程查找和杀死
- 微软算法100题35 求一个矩阵中最大的二维矩阵
- 正规矩阵 酉矩阵 对角矩阵
- hdu2031
- 【Echarts每天一例】-1
- 老李秘技:loadrunner11是否还支持dblib协议?
- 正则表达式为什么需要两个 \\
- iOS - JRDB - 基于sqlite3的通用数据库封装
- 正则表达式(一)
- 模拟Socket的通讯----(2)---客户端
- Android系统logcat实现分析
- Android为网络请求自定义加载动画