如果报这个错,肯定是classpath没设置好。
java -classpath . IterDemo

解决方案 »

  1.   

    你的next()方法连返回值都没有,编译怎么通过的??
    还有你的next操作中,index也没有加1,逻辑上也有问题,就算编译通过了,也会成死循环的
      

  2.   

    真是错误一大把啊!
     this.data = data; 什么意思???
      

  3.   

    IterDemo.java:23: missing return statement
        public Object next() {
                             ^
    1 error
      

  4.   

    死循环import java.util.Iterator;public class IterDemo implements Iterator
    {
        protected String[] data =
            {"one","two","three"};    protected int index = 0;    public IterDemo()
        {
            this.data = data;
        }    public boolean hasNext()
        {
            return(index < data.length);
        }    public Object next()
        {
            if(index >= data.length)
            {
                throw new IndexOutOfBoundsException("only" + data.length + "elements");
            }
            return data[index];
        }    public void remove()
        {
            throw new UnsupportedOperationException("this demo dows not implement the remove method");
        }    public static void main(String unused[])
        {
            IterDemo it = new IterDemo();
            while(it.hasNext())
            {
                System.out.println(it.next());
            }
        }
    }