Iterable interface is in java.lang package and Iterator interface in java.util package
public interface Iterable
The implementing classes for this interface is AbstractCollection, AbstractList, AbstractQueue, AbstractSequentialList, AbstractSet e.t.c
also iterator() is implemented in classes ArrayList , HashSet and few more classes.
Basically ArrayList override iterator() from AbstractList,
and in same way HashSet override iterator() from AbstractSet
public interface Iterator
public interface Iterable
Implementing this interface allows an object to be the target of
the "foreach" statement.
The implementing classes for this interface is AbstractCollection, AbstractList, AbstractQueue, AbstractSequentialList, AbstractSet e.t.c
also iterator() is implemented in classes ArrayList , HashSet and few more classes.
Basically ArrayList override iterator() from AbstractList,
and in same way HashSet override iterator() from AbstractSet
public interface Iterator
An iterator over a collection.
This interface has three methods :
Iterator
takes the place of
Enumeration
in the Java Collections Framework. Iterators
differ from enumerations in two ways:
- Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics.
- Method names have been improved.
This interface has three methods :
|
hasNext(), next(), remove() |
|
No comments:
Post a Comment