在Collections.sort(l);中会调用到compareTo方法
解决方案 »
- for 循环 如何写
- 一个初学者碰到的小问题
- 求高手指点我学java
- 关于java运行的简单问题
- 请假高手:正则表达式中怎么表示任意字符!
- JTable显示的记录中如何写双击某一行就会弹出窗口的事件?
- applet的小问题,就是有点不懂,谢谢了
- 请教高手,在用 ResultSet得到数据库查询结果时,如何通过它得到表的栏位名称?如:
- 谁能解释一下j2ee和j2se
- 有谁知道UltraEdit8.0b,EditPlus2.10a的注册码.急!急!!急!!!
- 如何在JFrame被关闭的时候让它执行另外一段代码后再关闭
- jbuilder中 import com.borland.jbcl.layout.*; 错误,请问什么原因啊?? 急!!!
public static <T extends Comparable<? super T>> void sort(List<T> list)Sorts the specified list into ascending order, according to the natural ordering of its elements. All elements in the list must implement the Comparable interface. Furthermore, all elements in the list must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the list).
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.The specified list must be modifiable, but need not be resizable.The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n log(n) performance. This implementation dumps the specified list into an array, sorts the array, and iterates over the list resetting each element from the corresponding position in the array. This avoids the n2 log(n) performance that would result from attempting to sort a linked list in place.