隨筆-1  評論-0  文章-2  trackbacks-0
          Iterator 和 Enumeration 有什么不同的地方?
          One key difference between an enumerator and an iterator is that the iterator will fail if the underlying collection changes.
          The Java 1.0/1.1 version of the iterator chose to invent a new name, “enumeration,” instead of using a term that everyone was already familiar with. The Enumeration interface is smaller than Iterator, with only two methods, and it uses longer method names: boolean hasMoreElements( ) produces true if this enumeration contains more elements, and Object nextElement( ) returns the next element of this enumeration if there are any more (otherwise it throws an exception).
          Enumeration is only an interface, not an implementation, and even new libraries sometimes still use the old Enumeration, which is unfortunate but generally harmless. Even though you should always use Iterator when you can in your own code, you must be prepared for libraries that want to hand you an Enumeration.
          posted on 2005-04-05 11:14 天下無名 閱讀(423) 評論(0)  編輯  收藏 所屬分類: 軟件碎屑

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 简阳市| 商都县| 延边| 大安市| 宜丰县| 台中市| 德昌县| 嘉兴市| 利津县| 都江堰市| 探索| 勃利县| 江山市| 万源市| 宝兴县| 彭州市| 九龙坡区| 广东省| 无棣县| 涡阳县| 利津县| 遂川县| 彰武县| 商洛市| 安仁县| 乌拉特后旗| 五指山市| 滁州市| 中西区| 泰安市| 昂仁县| 南召县| 建平县| 永川市| 左权县| 枝江市| 宾川县| 克拉玛依市| 老河口市| 阿克陶县| 新巴尔虎右旗|