泛型
Collections类
1.extends X是X的子类 2.super X是X的父类public static> void sort(List list) { Object[] a = list.toArray(); Arrays.sort(a); ListIterator i = list.listIterator(); for (int j=0; j > void sort(List list) { Object[] a = list.toArray(); Arrays.sort(a); ListIterator i = list.listIterator(); for (int j=0; j
测试类
Student没有实现比较接口Comparable,编译器报错。
代码
package sort;import java.util.ArrayList;import java.util.Collections;import java.util.List;public class ArrayListTest { public static void main(String[] args) { Lista = new ArrayList (); Collections.sort(a); }}复制代码