⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arrayiterator.java

📁 一个普通的计算器程序
💻 JAVA
字号:
//********************************************************************//  ArrayIterator.java       Authors: Lewis/Chase////  Represents an iterator over the elements of an array.//********************************************************************package jss2;import java.util.*;public class ArrayIterator<T> implements Iterator{   private int count;    // the number of elements in the collection   private int current;  // the current position in the iteration    private T[] items;    /******************************************************************     Sets up this iterator using the specified items.   ******************************************************************/   public ArrayIterator (T[] collection, int size)   {      items = collection;      count = size;      current = 0;   }   /******************************************************************     Returns true if this iterator has at least one more element     to deliver in the iteraion.   ******************************************************************/   public boolean hasNext()   {      return (current < count);   }   /******************************************************************     Returns the next element in the iteration. If there are no     more elements in this itertion, a NoSuchElementException is     thrown.   ******************************************************************/   public T next()   {      if (! hasNext())         throw new NoSuchElementException(); 	 current++;      return items[current - 1];    }   /******************************************************************     The remove operation is not supported in this collection.   ******************************************************************/   public void remove() throws UnsupportedOperationException   {      throw new UnsupportedOperationException();   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -