package collect;import java.awt.List;import java.util.ArrayList;import java.util.Collections;import java.util.Random;public class CollectionsTest { public void testSort1() { List<Integer> integerList=new ArrayList<Integer>();//好像错在上面The type List is not generic; it cannot be parameterized with arguments <Integer> Random random=new Random(); Integer k; for(int i=0;i<10;i++) { k=random.nextInt(100); }while(integerList.contains(k)); integerList.add(k); System.out.println("成功添加整数:"+k); System.out.println("---------排序前-------------"); for(Integer integer:integerList) { System.out.println("元素:"+integer); } Collections.sort(integerList); System.out.println("------------排序后------------"); for(Integer integer:integerList) { System.out.println("元素:"+integer); } } public static void main(String[] args) { // TODO Auto-generated method stub CollectionsTest ct=new CollectionsTest(); ct.testSort1(); }}
添加回答
举报
0/150
提交
取消