我的代码:
  import java.util.*;public class AddingGroups
{
public static void main(String[] args)
{
Collection<Integer> collection=new ArrayList<Integer>(Arrays.asList(1,2,3,4,5));
Integer[] moreInts={6,7,8,9,10};
Collections.addAll(Arrays.asList(moreInts));
Collections.addAll(collection, 11,12,13,14,15);
Collections.addAll(collection,moreInts);
List<Integer> list=Arrays.asList(16,17,18,19,20);
list.set(0,99);
for(Integer i: collection)
{
System.out.print(i+",");
}
System.out.println();
for(Integer i: list)
{
System.out.print(i+",");
}
}
}
编译器的提示:
  F:\JAVA1\JavaLesson\ThinkingInJava>javac AddingGroups.jav
注意:AddingGroups.java 使用了未经检查或不安全的操作。
注意:要了解详细信息,请使用 -Xlint:unchecked 重新编译。
问题:  为什么?  谢谢大家,这里我使用了泛型,但是还是不能通过编译器
       换在eclipse里却可以正确运行,为什么啊?
      谢谢大家赐教

解决方案 »

  1.   

    Collections.addAll(Arrays.asList(moreInts));
    Collections.addAll(collection, 11,12,13,14,15);
    Collections.addAll(collection,moreInts);
    List <Integer> list=Arrays.asList(16,17,18,19,20);
    这几句你没有使用泛型只是警告,编译通过了
      

  2.   

    好像应该这样,初学,记不太清了
     Collections.<Integer>addAll(Arrays.<Integer>asList(moreInts));