Java Iterator from getEmptyIterator()

Here you can find the source of getEmptyIterator()

Description

Returns an empty iterator

License

Open Source License

Parameter

Parameter Description
T a parameter

Declaration

public static <T> Iterator<T> getEmptyIterator() 

Method Source Code


//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.");
            }

        };
    }
}

Related

  1. get(Iterator iterator, int position)
  2. getAll(Iterator it)
  3. getAt(Iterator it, int pos)
  4. getCommaSeparatedValue(Iterator it)
  5. getDestinationType(ImageReadParam param, Iterator imageTypes)
  6. getEnumeratedObjectCount(Iterator objects)
  7. getFirstChildrendIterator(List children)
  8. getIndexInIterator(Iterator iterator, int index)
  9. getIterable(final Iterator i)