If you implement Collection, you also implement iterator( ), and just implementing iterator( ) alone requires only slight less effort than inheriting from AbstractCollection.

解决方案 »

  1.   

    如果你要实现Collection,来特别定制iterator(), 那就建议你从AbstractCollection类继承,这样会减少很多工作。这个是“缺省适配器模式”的应用
      

  2.   


    比从抽象容器类继承省力???
    just implementing iterator( ) alone requires only slight less effort than inheriting from AbstractCollection.
    其实省略了by:
    just implementing iterator( ) alone requires only slight less effort than by inheriting from AbstractCollection.
      

  3.   

    requires only slight less effort 是什么意思?
      

  4.   

    just implementing iterator( ) alone 是通过 inheriting from AbstractCollection的,它比直接实现Collection接口 requires only slight less effort。
      

  5.   

    why仅仅单独实现迭代器只比从抽象容器类继承省力?从抽象容器类继承不就实现了迭代器吗?
      

  6.   

    啊哈,Iterator是设计模式的经典之作啊,楼主好好理解一下JDK容器里的Iterator吧,呵呵
      

  7.   

    原文翻译  java编程思想中文版第P240: “从本例中,你可以看到,如果你实现Collection,就必须实现iterator(),并且只拿实现iterator()与继承AbstractCollection相比,花费的代价只有略微减少。”