吴登广
2015-08-08 16:12
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
import java.util.Collections;
你没导入包
你调用的是你的类的方法?
上面List那块是不是忘写了个空格?
Java入门第三季
409776 学习 · 4546 问题
相似问题