Data Structure
Collection
| «interface»java.lang.Iterable<E> |
|---|
| +iterator(): Iterator<E> |
| «interface»java.util.Collection<E> |
|---|
| +add(o: E): boolean |
| +addAll(c: Collection<? extends E>): boolean |
| +contains(o: Object): boolean |
| +clear(): void |
| +containsAll(c: Collection<?>): boolean |
| +equals(o: Object): boolean |
| +hashCode(): int |
| +isEmpty(): boolean |
| +remove(o: Object): boolean |
| +removeAll(c: Collection<?>): boolean |
| +retainAll(c: Collection<?>): boolean |
| +size(): int |
| +toArray() : Object[] |
| «interface»java.util.Iterator<E> |
|---|
| +hasNext() : boolean |
| +next() : E |
| +remove(): void |
All the concrete classes in the Java Collections Framework implement the java.lang.Cloneable and java.io.Serializable interfaces except that java.util.PriorityQueue does not implement the Cloneable interface. Thus, all instances of Cloneable except priority queues can be cloned and all instances of Cloneablecan be serialized.
Iterator<E> it = collection.iterator();
while (it.hasNext()) {
System.out.print(it.next() + " ");
}