android-interview-questions icon indicating copy to clipboard operation
android-interview-questions copied to clipboard

Difference between enumeration and iteration

Open manishkaushik900 opened this issue 4 years ago • 2 comments

Enumeration don't have remove() method

Iterator have hasNext(), next(), remove() method. Enumeration have hasMoreElement(), nextElement() method only

manishkaushik900 avatar Jun 03 '21 16:06 manishkaushik900

@manishkaushik900 It seems to be fix here

iamutkarshtiwari avatar Nov 25 '21 11:11 iamutkarshtiwari

---> Enumeration:- Like a museum tour, it guides you through elements one by one, letting you observe but not interact. Think of legacy collections like Vector and Stack.

---> Iteration:- Like a playground, it lets you freely explore and even modify elements. Works with modern collections like ArrayList and HashMap.

While Enumeration is read-only, while Iteration lets us to add, remove, or change the elements.

Iteration is more flexible and works with most collections.

RushiBhatti avatar Feb 23 '24 17:02 RushiBhatti