Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Iterator;

import java.util.NoSuchElementException;

public class Main {
    public static <ELEMENT_TYPE> Iterator<ELEMENT_TYPE> unmodifiableEmptyIterator() {
        return new Iterator<ELEMENT_TYPE>() {

            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public ELEMENT_TYPE next() {
                throw new NoSuchElementException();
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException("This collection is imutable and empty");
            }

        };
    }
}