Java examples for Collection Framework:Iterator
empty Iterator
// Copyright (c) 2006 - 2008, Clark & Parsia, LLC. <http://www.clarkparsia.com> //package com.java2s; import java.util.Iterator; import java.util.NoSuchElementException; public class Main { private static final Iterator<Object> EMPTY_ITERATOR = new Iterator<Object>() { public boolean hasNext() { return false; }/*from ww w . jav a 2 s . c om*/ public Object next() { throw new NoSuchElementException(); } public void remove() { throw new UnsupportedOperationException(); } }; @SuppressWarnings("unchecked") public static final <T> Iterator<T> emptyIterator() { return (Iterator<T>) EMPTY_ITERATOR; } }