- List集合(接口类)
是Collection接口类的子接口,也是最常用的接口。此接口对Collection接口进行了大量的扩展,List集合里的元素允许重复。
具体实现类
- ArrayList实现类
实现可变数组
public class TestArrayList {
private static Student printArrayList(ArrayList<Student> s) {
System.out.println("当前元素结合:");
for(int i =0; i<s.size();i++){
System.out.println(s.get(i));
}
return null;
}
public static void main(String[] args) {
Student s1 = new Student("bob", false);
Student s2 = new Student("李四", true);
ArrayList<Student> arrayList = new ArrayList<Student>();
arrayList.add(s1);
arrayList.add(s2);
printArrayList(arrayList);
}
}
当前元素结合:
com.gavin29.Student@139a55
com.gavin29.Student@1db9742
- LinkedList实现类
功能最强大