数组等等的排序,Collections.sort(LIST)

1.Collections.sort() 来排序

while(resultSet.next())
{
      scoreList.add(resultSet.getInt("score")); //从某处获得数据,加入到一个list里
}
Collections.sort(scoreList); //对这个有数据的 list 用 Collections.sort() 排序

for(int i = 0;i<scoreList.size();i++)
{
System.out.println(scoreList.get(i)); //全部打出来看看
}

输出:
6
7
8
8
8
8
8
8
9
10

2.不用的话。。。。

输出:
10
9
10
10
10
9
8
9
.......
乱的

你可能感兴趣的:(Collections)