隨筆-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)  編輯  收藏 所屬分類: 軟件碎屑

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


          網站導航:
           
          主站蜘蛛池模板: 海阳市| 铁岭市| 栾城县| 霍邱县| 淮滨县| 大名县| 双辽市| 大庆市| 南安市| 盖州市| 红河县| 南投市| 静乐县| 水城县| 双牌县| 罗平县| 云南省| 临江市| 宁波市| 育儿| 澎湖县| 天门市| 民权县| 疏附县| 永安市| 平泉县| 寿阳县| 射阳县| 宁阳县| 鸡泽县| 南宫市| 金沙县| 龙门县| 巴彦淖尔市| 青河县| 韩城市| 东兰县| 游戏| 金平| 永登县| 华阴市|