import java.util.Collections; import java.util.LinkedList; import java.util.List; public class Test { List list = new LinkedList(); public static void main(String[] args) { List list = new LinkedList(); for ( int i = 0 ; i < 9 ; i ++ ) { list.add( " a " + i); } Collections.sort(list); // 顺序排列 System.out.println(list); Collections.shuffle(list); // 混乱的意思 System.out.println(list); Collections.reverse(list); // 倒序排列 System.out.println(list); System.out.println(Collections.binarySearch(list, " a5 " )); // 折半查找 } }
转自:https://www.cnblogs.com/chen-lhx/p/8961297.html