ArrayList<Integer> list = testService.getList();Set<Integer> set =newHashSet(list);for(int i =0; i <=Integer.MAX_VALUE; i++){// 时间复杂度O(1)
set.contains(i);}
使用String.valueOf(value)代替""+value
枚举的属性字段必须是私有不可变
使用BigDecimal.valueOf(1.2D) 代替 new BigDecimal(1.2D)
数组遍历使用索引遍历,集合使用迭代器遍历
能使用基本数据类型尽量使用基本数据类型
数组拷贝使用 System.arraycopy()
使用移位操作代替乘除
// 右移代替除(等价与16/4) a>>n 等价于 a/2的n次方 int i =16>>2;// 左移代替除(等价与2*8) a<<n 等价于 a*2的n次方int j =2<<3;