//用fill方法改变部分集合内容
import java.util.*;
class Noname
{
public static void main(String[] args)
{
String str[] = {"dd","aa","bb","cc","ee"};
List<String> list = Arrays.asList(str);
List<String> subList = list.subList(0, 2);
Collections.fill(subList, "aaa"); //用aaa填充前面两个元素
//Collections.fill(list, "aaa");//用aaa填充全部元素
System.out.println(list);
}
}
|
|