线性表(用数组存储数据)
线性表是按顺序存储数据时常用的一种数据结构。例如,学生的列表、空房间的列表、城市的列表以及书籍的列表。使用数组存储线性表的元素是实现线性表的其中一种方式。
下面以袋集合为例,介绍数组线性表。袋可以定义为一种没有按照任何特定位置关系来组织其元素的组合。从概念上讲,它类似于放置物品的真实袋子。一旦将元素放入袋中,将不能确定袋中元素的相对位置。如果进入袋中盲目地取出一个元素,则元素的取出几率是相同的。袋是一种非线性集合。这种集合中的元素实质上根本就没有任何组织方式。袋中的元素相互间没有任何固有关系,而且元素也没有按照特定的次序添加到袋中。
UML描述

接口实现
?
import java.util.*;public class ArrayIterator implements Iterator{ private int count; private int current; private Object[] items; // Set up this iterator using the specified items. public ArrayIter(Object[] collection, int size) { items = collection; count = size; current = 0; } // Returns true if this iterator has at least one more element to deliver in the iteraion. public boolean hasNext() { return (current < count); } // Returns the next element in the iteration. If therer are no more elements in this itertion,a NoSuchElementException is thrown. public Object next() { if(! hasNext()) throw new NoSuchElementException(); current ++; return items[current - 1]; }