Here you can find the source of getEmptyIterator()
Parameter | Description |
---|---|
T | a parameter |
public static <T> Iterator<T> getEmptyIterator()
//package com.java2s; import java.util.Iterator; import java.util.NoSuchElementException; public class Main { /**/* w w w .j av a2s. co m*/ * Returns an empty iterator * * @param <T> * @return */ public static <T> Iterator<T> getEmptyIterator() { return new Iterator<T>() { @Override public boolean hasNext() { return false; } @Override public T next() { if (!hasNext()) throw new NoSuchElementException(); return null; } @Override public void remove() { throw new UnsupportedOperationException("The remove operation is not supported by this iterator."); } }; } }