GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 175 of 502    Print  
Tell me the differences between enumeration and iteration?Which can use where in realtime?

  
Total Answers and Comments: 13 Last Update: September 22, 2009     Asked by: chandu 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: masthan02
 
Enumeration and Iterator are the interface available in java.util package. Enumeration contains 2 methods namely hasMoreElements() & nextElement().

Iterator contains three methods namely hasNext(), next(),remove().
Using remove() we can also delete the objects but Enumeration interface does not support this feature.

Above answer was rated as good by the following members:
janmaijais
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
November 21, 2005 02:57:13   #1  
Navdeep        

RE: Tell me the differences between enumeration and it...
Enumeration deals with objects while iteration deals with values only. Enumeration is used when we use vector hashtable etc while iteration are used in while loop for loop etc
 
Is this answer useful? Yes | No
November 27, 2005 09:10:24   #2  
praveen        

RE: Tell me the differences between enumeration and it...

Hi !

Both will help you to travel into collection bag But Enumeration is a leagsy classes and it comes with java1.1 Iterater they have introduced in Collection framework.

In enumeration we can modify the collection objects but throw Iterator it is possible.


 
Is this answer useful? Yes | No
December 09, 2005 09:16:38   #3  
x Member Since: December 2005   Contribution: 3    

RE: Tell me the differences between enumeration and it...
Enumerator and Iterator are almost same.But in Iterator there is one extra method called remove .and iterator is part of the new collection class.Java API says to use more of iterator than Enumerator which is kind of old class.
 
Is this answer useful? Yes | No
December 14, 2005 05:01:30   #4  
viji        

RE: Tell me the differences between enumeration and it...
Enumeration and Iterator both are interfaces present in util package. Enumeration is a legacy interface which does not come under the collection framework wheras Iterator is an interface present in the collection framework. All the legacy classes like Stack Vector Hashtable Properties can use Enumeration for enumerating the elements from the collection. The classes under the collection framework like ArrayList LinkedList HashSet Tree Set etc can use the Iterator interface
 
Is this answer useful? Yes | No
March 27, 2006 07:28:17   #5  
gursharn        

RE: Tell me the differences between enumeration and it...

hi!!!

Enumeration does not have remove method but iteration has.......


 
Is this answer useful? Yes | No
July 13, 2006 02:49:40   #6  
Mahantesh V Kabadagi        

RE: Tell me the differences between enumeration and it...

Both are used to travel objects one by one But Enumeration is a leagsy classes and it comes with java1.1 Iterater they have introduced in Collection framework.

Enumeration can be used for Collection objects as well as Iterator can be used for legacy classes.

Enumeration acts as Read-only interface because it has the methods only to travels and fetch the objects where as using Iterator we can manipulate the objects also like adding and removing the objects.

So Enumeration is used when ever we want to make Collection objects as Read-only.


 
Is this answer useful? Yes | No
October 04, 2006 06:12:25   #7  
Chandrakant        

RE: Tell me the differences between enumeration and it...

Both have almost same functionality but Iterator has little bit extra added value in it......

Iterator takes the place of Enumeration in the Java collections framework. Iterators differ from enumerations in two ways:

  • Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics.
  • Method names have been improved.

 
Is this answer useful? Yes | No
August 11, 2008 03:38:27   #8  
usguru Member Since: June 2008   Contribution: 6    

RE: Tell me the differences between enumeration and iteration?Which can use where in realtime?
Iterator has remove() method Enumeration does not have this method.
 
Is this answer useful? Yes | No
August 25, 2008 07:13:47   #9  
uday.ilapakurthi Member Since: August 2008   Contribution: 1    

RE: Tell me the differences between enumeration and iteration?Which can use where in realtime?
Enumeration - In enumeration there is no method to remove the object from the collection and very difficult to remember the enumeration methods.

Iteration - In iteration we have remove method and also we can easily remember the methods.

 
Is this answer useful? Yes | No
August 26, 2008 01:07:27   #10  
Karuna Reddy Member Since: June 2007   Contribution: 40    

RE: Tell me the differences between enumeration and iteration?Which can use where in realtime?
In Enumeration we usly fetch the data only ie read only while Iteration can done all the manipulations like read update and insert and remove also

When the requirment like only want to show the values then go for Enumeration and when we want to change the values then we go for Iteration

 
Is this answer useful? Yes | No
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape