GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java

 Print  |  
Question:  Tell me the differences between enumeration and iteration?Which can use where in realtime?



July 07, 2006 02:49:40 #6
 Mahantesh V Kabadagi   Member Since: Visitor    Total Comments: N/A 

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.

     

 

Back To Question