Why java.lang.Iterable depends on java.util.Iterator# Java - 爪哇娇娃
Y*G
1 楼
Should java.lang not depend on anything else? Why Iterator not in java.lang
package?
package java.lang;
import java.util.Iterator;
/**
* Implementing this interface allows an object to be the target of
* the "foreach" statement.
*
* @param the type of elements returned by the iterator
*
* @since 1.5
*/
public interface Iterable {
/**
* Returns an iterator over a set of elements of type T.
*
* @return an Iterator.
*/
Iterator iterator();
}
package?
package java.lang;
import java.util.Iterator;
/**
* Implementing this interface allows an object to be the target of
* the "foreach" statement.
*
* @param
*
* @since 1.5
*/
public interface Iterable
/**
* Returns an iterator over a set of elements of type T.
*
* @return an Iterator.
*/
Iterator
}