大家幫我看看為什么我會報錯
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
}
}
詳細的是 The method sort(list<Integer>)is undefined for the type Collections
2015-08-09
import java.util.Collections;
你沒導入包
你調用的是你的類的方法?
2015-08-08
上面List那塊是不是忘寫了個空格?