amitshekhariitbhu / android-interview-questions

Your Cheat Sheet For Android Interview - Android Interview Questions and Answers
https://outcomeschool.com
Apache License 2.0
11.2k stars 2.22k forks source link

Difference between enumeration and iteration #97

Open manishkaushik900 opened 3 years ago

manishkaushik900 commented 3 years ago

Enumeration don't have remove() method

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

iamutkarshtiwari commented 2 years ago

@manishkaushik900 It seems to be fix here

RushiBhatti commented 6 months ago

---> 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.