- public class FillingList {
- public static void main(String[] args) {
- List<Integer> list = new ArrayList<Integer>(Collections.nCopies(4,
- new Integer(2)));
- System.out.println(list);
- Collections.fill(list, new Integer(1));
- System.out.println(list);
-
- // List<Integer> list=new ArrayList<Integer>();
- // list=Collections.nCopies(4, new Integer(1));
- // System.out.println(list);
- // Collections.fill(list, new Integer(1));
- // System.out.println(list);
- }
- }
复制代码
没有注释的代码 运行正常,注释的代码有异常,请详解 |
|