Results 1 to 5 of 5

Thread: What is the difference between Iterator and Enumeration in Java?

  1. #1
    Join Date
    Dec 2009
    Posts
    12

    What is the difference between Iterator and Enumeration in Java?

    I am intermediate programmer in the programming world. Currently i am learning the programming language like Core Java, C++, C sharp, .NET and DBMS. I have got a mini project to develop in JAVA and one of its goal is to use the enumeration or iterator, but i don't know what is enumeration and iterator and what is the difference between them? Please help me in making mini my project.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: What is the difference between Iterator and Enumeration in Java?

    Good question ask, programmer mostly gets confused between the enumeration and iterator. The Enumeration(enums) is use for the iterating over a given collection and usually of unknown size. The Iterator also has the similar or same purpose but enumeration do not allow modification of the collection, whereas by using the Iterator we can achieve it. Enumeration deals with objects while iteration deals with values only. Hope your problem will be solved.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: What is the difference between Iterator and Enumeration in Java?

    One of the major difference between the enumeration and iterator is that the iterator is a fail-safe. According to me, the enumeration and iterator is mainly use to count the number of elements and view it. But also note that iterator comes with the additional method for deleting elements. Enumeration and Iterator are interfaces in java.util package. Enumeration are old interface, whereas Iterator are new interface. Hope your problem is fix.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: What is the difference between Iterator and Enumeration in Java?

    I personally think the Enumerator and Iterator are almost similar to each other. The advantage to Iterator is presence one extra method called remove and iterator is part of the new collection class. Enumeration works with objects while iteration works with values only. Enumeration is mainly use whenever we use vector hashtable( legacy classes), whereas iteration are used in while loop for loop etc. Hope your problem will be fix.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: What is the difference between Iterator and Enumeration in Java?

    The major difference is that enumeration(enum) was the old interface and the iterator is the new interface belonging to the Collection framework which was introduced by JDK 1.2. The functionality of this interface (Enumeration) is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation. Hope your problem will be solved.

Similar Threads

  1. Synchronize an iterator in java
    By Remedy in forum Software Development
    Replies: 5
    Last Post: 18-02-2010, 01:28 AM
  2. Enumeration in C sharp
    By Harper 21 in forum Software Development
    Replies: 5
    Last Post: 27-01-2010, 09:52 AM
  3. Difference between Structure, Classes and Enumeration
    By Henryosa in forum Software Development
    Replies: 6
    Last Post: 22-01-2010, 11:02 AM
  4. what is the difference between c and java?
    By Linoo in forum Software Development
    Replies: 5
    Last Post: 28-11-2009, 05:11 PM
  5. What is the difference between CORBA and Java RMI?
    By Triple-X in forum Software Development
    Replies: 3
    Last Post: 03-09-2009, 05:59 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,661,676.06446 seconds with 17 queries