collections
来源:互联网 发布:考研英语翻译人工智能 编辑:程序博客网 时间:2024/04/27 16:35
操作Collection以及Map的工具类:Collections
reverse(List):反转 List 中元素的顺序
shuffle(List):对 List 集合元素进行随机排序
sort(List):根据元素的自然顺序对指定 List 集合元素按升序排序
sort(List,Comparator):根据指定的 Comparator 产生的顺序对 List 集合元素进行排序
swap(List,int, int):将指定 list 集合中的 i 处元素和 j 处元素进行交换
Object max(Collection):根据元素的自然顺序,返回给定集合中的最大元素
Object max(Collection,Comparator):根据 Comparator 指定的顺序,返回给定集合中的最大元素
Object min(Collection)
Object min(Collection,Comparator)
int frequency(Collection,Object):返回指定集合中指定元素的出现次数
void copy(List dest,List src):将src中的内容复制到dest中
//实现List的复制
//List list1 = new ArrayList();//错误的实现方式
List list1 = Arrays.asList(new Object[list.size()]);
Collections.copy(list1, list);
boolean replaceAll(List list,Object oldVal,Object newVal):使用新值替换 List 对象的所有旧值
//通过如下的方法保证集合的线程安全性。
synchronizedCollection(Collection<T> c) :Returns a synchronized (thread-safe) collection backed by the specified collection.
synchronizedList(List<T> list) :Returns a synchronized (thread-safe) list backed by the specified list.
synchronizedMap(Map<K,V> m) :Returns a synchronized (thread-safe) map backed by the specified map.
synchronizedSet(Set<T> s) :返回一个线程安全的set集合。
- Collections
- Collections
- Collections
- collections
- Collections
- COLLECTIONS
- Collections
- Collections
- collections
- Collections
- Collections
- collections
- Collections
- Collections
- collections
- Collections
- Collections
- collections
- 希尔排序的实现
- 趋势科技对ShellshockBash漏洞的解决方案说明
- java/android 统计文件夹大小及删除文件夹下所有文件和路径
- Google Chrome浏览器调试方法
- JVM深入学习笔记二:Java JIT编译
- collections
- oracle 11gR2用exp无法导出空表的解决方法
- Google Chrome调试js代码2
- javaScript常用的东东
- 机房收费系统合作版(二)——初识Git
- ZOJ 2314/SGU194 Reactor Cooling
- LeetCode Generate Parentheses Sl
- 编写memcpy函数
- android如何查看当前工程哪些profile是打开的