集合与数组的相互转换:
* Arrays:
* 数组转集合public static <T> List<T> asList(T... a) 注意生成的集合长度不可变
*/
public class Demo4 {
public static void main(String[] args) {
List<String> asList = Arrays.asList("王宝强","王祖蓝","许三多","傻根","顺溜");
Iterator<String> iterator = asList.iterator();
while (iterator.hasNext()) {
String string = iterator.next();
System.out.println(string);
}
System.out.println("========================");
asList.set(0, "冯宝宝");
for (String string : asList) {
System.out.println(string);
}
asList.add("宝贝儿");
asList.remove(0);
}
}
|
|