集合:Collection API 以及List

来源:互联网 发布:mac iphone 蓝牙 网络 编辑:程序博客网 时间:2024/05/21 09:43

集合类:

1.Collection API

*提供了集合和收集的功能

*包含了一系列的接口和类

*主要包含了三大类Collection接口:有两个子接口

List:记录元素的保存顺序,且允许有重复元

Set:不记录元素的顺序,且不允许有重复元素

Map接口即映射:键值对的集合

2.LIst接口:

*List接口:线性表

主要实现的是ArrayList,LinkList,以及早期的vector

List接口:

public interface List<E> extends Collection<E>{

    E get(int index);

    E set(int index);

    void add (int index,E element);

    E remove(int index);

    int indexOf(Object O);

    ....

Iterator:迭代器遍历列表

在JDK 1.5以后增强了for语句

for(Element e : List) dosometing(e);




原创粉丝点击