集册 Java实例教程 空的迭代器

空的迭代器

欢马劈雪     最近更新时间:2020-01-02 10:19:05

536
空迭代器

// Copyright (c) 2006 - 2008, Clark & Parsia, LLC. <http://www.clarkparsia.com>

//package com.nowjava;/** from nowjava.com - 时  代  Java**/


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;

        }


        public Object next() {

            throw new NoSuchElementException();

        }


        public void remove() {

            throw new UnsupportedOperationException();

        }

    };
/**from N o w  J a v a  . c o m**/

    @SuppressWarnings("unchecked")

    
展开阅读全文