What are the Legacy classes?

Early versions of java did not include Collections framework. Instead it defined several classes and one interface to store objects. When collection came these classes reengineered to support the Collection interfaces. These old classes are known are legacy classes.
Legacy classes-Dictionary,HashTable,Properties, Stack, Vector
Legacy interface- Enumeration.

• Enumeration ---Interface
• Dictonary ------Abstract class
• Hashtable -----Concrete class
• Properties -----Concrete class
• Vector -----Concrete class
• Stack -----Concrete class


Only values- Stack, Vector
Key/value pair – Dictionary, HashTable, Properties


Enumeration interface:
It defines the method by which we can enumerate(obtain one at a time) through the elements. The legacy interface is suppressed by Iterator.
It has two methods:
Boolean hasMoreElements()
nextElement()

9 comments:

  1. what is difference between Enumeration and Iterator

    ReplyDelete
    Replies
    1. Check this,
      http://newjavafaqs.blogspot.in/2010/07/what-is-difference-enumeration-and.html

      Delete
    2. Both Iterator and Enumeration interfaces acts like cursors in collection.But Enumeration Interface is applied for only legacy classes(old classes) like vector and stack also with enumeration we can only read but with itereator we can also remove the elements....

      Delete
  2. @Ashi: Do you know everything about java Ashi... nobody is perfect here and that is the reason you even come to this page... so stop dominating others...

    @Rekha: I only know two differences b/w Enumeration and Iterator
    1) Enumeration has long name for methods but Iterator has short.
    2) Enumeration does not have remove method which is present in Iterator.

    I hope this will clear your issue. Best of luck.

    ReplyDelete
    Replies
    1. very good Sudhanshu not for your explination for your attitude

      Delete
    2. Thanks Sudhanshu,
      I agree with Balaji

      Delete
  3. @Ashi
    Please avoid these kind of comments.
    Or I will be forced to block you.

    ReplyDelete