Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Iterator;

public class Main {
    /**
     * Generate an iterator for an array
     * 
     * @param array
     * @return
     */
    public static <T> Iterator<T> getIterator(final T[] array) {
        return new Iterator<T>() {
            private int i = 0;

            public boolean hasNext() {
                return i < array.length;
            }

            public T next() {
                return array[i++];
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
}