原以为fill方法是填充collection的。测试:
显示[] , 没添进去。 后来得知fill方法是替换已存在元素的。不能添加~
[hello, world]
[joey, joey]
List<String> list = new ArrayList<String>(6);
Collections.fill(list,"hello world!");
System.out.println(fill);
显示[] , 没添进去。 后来得知fill方法是替换已存在元素的。不能添加~
List<Stirng> list = new ArrayList<String>(Arrays.asList("hello","world"));
System.out.println(list);
Collections.fill(list, "joey");
System.out.println(list);
[hello, world]
[joey, joey]