javatools.datatypes
Class IterableForIterator<T>
java.lang.Object
javatools.datatypes.IterableForIterator<T>
- All Implemented Interfaces:
- java.lang.Iterable<T>
public class IterableForIterator<T>
- extends java.lang.Object
- implements java.lang.Iterable<T>
This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools).
It is licensed under the Creative Commons Attribution License
(see http://creativecommons.org/licenses/by/3.0) by
the YAGO-NAGA team (see http://mpii.de/yago-naga).
This class allows to use an iterator in a for-each-loop.
Example:
for(String s : new Scanner("Scan this string")) {
// Compiletime error, because Scanner is an Iterator but not Iterable
}
for(String s : new IterableForIterator<String>(new Scanner("Scan this string"))) {
// works fine
}
Method Summary |
java.util.Iterator<T> |
iterator()
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
iterator
public java.util.Iterator<T> iterator
IterableForIterator
public IterableForIterator(java.util.Iterator<T> iterator)
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator
in interface java.lang.Iterable<T>