大家?guī)臀铱纯礊槭裁次視箦e
package?com.imooc.collection; import?java.util.ArrayList; import?java.util.List; import?java.util.Random; public?class?Collections?{ public?void?testSort1(){ List<Integer>integerList=new?ArrayList<Integer>(); Random?random=new?Random(); Integer?k; for(int?i=0;i<10;i++){ do{k=random.nextInt(100);}while(integerList.contains(k)); integerList.add(k); } System.out.println("------------排序前-------------"); for?(Integer?integer?:?integerList)?{ System.out.println("元素:"+integer); } ???Collections.sort(integerList); } public?static?void?main(String[]?args)?{ //?TODO?Auto-generated?method?stub } }
詳細(xì)的是 The method sort(list<Integer>)is undefined for the type Collections
2015-08-09
import java.util.Collections;
你沒導(dǎo)入包
你調(diào)用的是你的類的方法?
2015-08-08
上面List那塊是不是忘寫了個空格?