package com.bjsxt.chap7;
import java.util.*;
public class TestList {
public static void main(String[] args) {
List l1 = new LinkedList();
for (int i = 0; i <= 5; i++) {
l1.add("a" + i);
}
System.out.println(l1);
l1.add(3, "a100");
System.out.println(l1);
l1.set(6, "a200");
System.out.println(l1);
System.out.print((String)l1.get(2) + " ");
System.out.println(l1.indexOf("a3"));
l1.remove(1);
System.out.println(l1);
System.out.println("--------------------------");
List L1 = new LinkedList();
List L2 = new LinkedList();
for (int i = 0; i <= 9; i++) {
L1.add("a" + i);
}
System.out.println(L1);
Collections.shuffle(L1); // 随机
System.out.println(L1);
Collections.reverse(L1); // 逆序
System.out.println(L1);
Collections.sort(L1); // 排序
System.out.println(L1);
System.out.println(Collections.binarySearch(L1, "a5"));
}
}