[/url] [url=file:///F:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/overview-summary.html]Overview
Class
JavaTM 2 Platform
Std. Ed. v1.4.2
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
java.util
Interface IteratorAll Known Subinterfaces: ListIterator All Known Implementing Classes: BeanContextSupport.BCSIterator public interface IteratorAn iterator over a collection. Iterator takes the place of Enumeration in the Java collections framework. Iterators differ from enumerations in two ways: iterator重载了collection。在Java集合框架中Iterator用来替代Enumeration。Iterator和Enumeration 在以下两方面不同:
Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics. Iterator允许调用者使用好的语义在迭代中从底层集合中删除元素。 Method names have been improved. 方法名称有改进。 This interface is a member of the Java Collections Framework. 该接口是Java集合框架成员。
Since: 1.2 See Also: Collection, ListIterator, EnumerationMethod Summary
boolean
hasNext()
Returns true if the iteration has more elements. 如果迭代中还有元素返回true。
next()
Returns the next element in the iteration. 返回迭代中的下一个元素。
void
remove()
Removes from the underlying collection the last element returned by the iterator (optional operation). 迭代器从底层集合中删除刚返回的元素(可选操作)。
Method Detail
hasNextpublic boolean hasNext()
Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.) 如果迭代中还有元素返回true。(换言之,如果next返回一个元素而不是抛出异常的话,返回true。)
Returns: true if the iterator has more elements. 如果迭代中还有元素返回true。nextpublic Object next()
Returns the next element in the iteration. 返回迭代中的下一个元素。
Returns: the next element in the iteration. 迭代中下一个元素。 Throws: NoSuchElementException - iteration has no more elements. 如果迭代中没有元素时抛出。removepublic void remove()
Removes from the underlying collection the last element returned by the iterator (optional operation). This method can be called only once per call to next. The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method. 迭代器从底层集合中删除刚返回的元素(可选操作)。该方法只能在每次调用next后调用一次。 如果底层集合已被修改而迭代器正在进程中(除了调用本方法),则迭代器的行为不能确定。
Throws: UnsupportedOperationException - if the remove operation is not supported by this Iterator. 如果Iterator不支持remove操作时抛出。 IllegalStateException - if the next method has not yet been called, or the remove method has already been called after the last call to the next method. next方法还未调用,或在上一次调用next后已调用过remove方法时抛出。[/url][url=file:///F:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/overview-summary.html]Overview
Class
JavaTM 2 Platform
Std. Ed. v1.4.2
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.