Code example for Iterator

Methods: hasNext, next

0
    } 
 
    public String lookup(String prefix) {
        try { 
            Iterator<String> it = getPrefixedBy(prefix).iterator();
            if (!it.hasNext())
                return null; 
            return it.next();
        } catch(InterruptedException ie) {
            throw new IllegalStateException(ie);
        } 
    } 
 
    public Iterator<String> iterator() {
        try { 
            return getPrefixedBy("").iterator();
        } catch(InterruptedException ie) {
            throw new IllegalStateException(ie);
        } 
    }