Collections接口的静态方法基本操作
来源:互联网 发布:mysql 分表 hash 编辑:程序博客网 时间:2024/05/10 12:43
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
*
*对Collections进行一些自身提供的基本静态方法的操作
*/
public class CollectionDemo1 {
public static void main(String[] args) {
List<String > nList=new ArrayList<String >();
nList.add("zhangsan");
nList.add("lisi");
nList.add("wangwu");
nList.add("rose");
nList.add("jack");
nList.add("mary");
System.out.println("操作前");
for (String s : nList) {
System.out.println(s+" ");
}
System.out.println();
System.out.println("交换顺序后");
Collections.swap(nList, 1, 2);
for (String s : nList) {
System.out.println(s+" ");
}
System.out.println();
System.out.println("自然排序后");
Collections.sort(nList);
for (String s : nList) {
System.out.println(s+" ");
}
System.out.println();
System.out.println("二分法查找后");
System.out.println(Collections.binarySearch(nList, "jack"));
System.out.println();
System.out.println("打乱顺序后");
Collections.shuffle(nList);
for (String s : nList) {
System.out.println(s+" ");
}
System.out.println();
System.out.println("填充后");
Collections.fill(nList, "xiaoming");
for (String s : nList) {
System.out.println(s+" ");
}
}
}
0 0
- Collections接口的静态方法基本操作
- 数组Array和操作集合Collections的静态方法;
- java-------collections提供的一些静态方法
- Collections静态方法sort
- Collections中的静态方法
- Collections.静态方法()
- java中Collections是由在 collection 上进行操作或返回 collection 的静态方法组成。
- [php] 静态方法 接口 链式操作
- 静态单链表的基本操作
- Collections类常用静态方法
- DAO接口的基本操作
- Dao 接口的基本操作
- Map接口的基本方法
- 树的基本操作,静态法
- 静态链表的所有基本操作
- 串的静态顺序存储基本操作
- 静态链表的基本操作
- 静态顺序表的基本操作
- hashset的应用及注意事项,以及案例分析和详细注释
- CodeForces 479E E. Riding in a Lift
- JavaSE入门学习23:Java面向对象之构造方法
- UVa 11584 Partitioning by Palindromes dp : 线性结构上dp LIS
- iOS 时间戳与时间互换
- Collections接口的静态方法基本操作
- FMDB 的简单说明
- 非阻塞(nonblock)socket接口会否出现EINTR错误
- Qualcomm DragonBorad 410c GET!
- Collection类及常用API
- AsyncTask详解
- 计算一组整数的最大值和最小值----静态内部类的使用
- px、dp和sp,这些单位有什么区别?
- 一道Java面试题,静态方法在Java中是一种非虚方法 http://blog.csdn.net/time_hunter/article/details/9074107