android-interview-questions
android-interview-questions copied to clipboard
Difference between enumeration and iteration
Enumeration don't have remove() method
Iterator have hasNext(), next(), remove() method. Enumeration have hasMoreElement(), nextElement() method only
@manishkaushik900 It seems to be fix here
---> 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.