This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In the ServletConfig Interface we have a method getInitParameterNames() whose signature is
Enumeration getInitParameterNames() , now can anyone explain what does an Enumeration type have to do in the return type of getInitParameterNames() method .
An enumeration is an object that generates elements one at a time, used for passing through a collection, usually of unknown size. The traversing of elements can only be done once per creation. Here, we use it get the names of the initial parameters, which are unknown in size. It's logically like a Collection, but, in Collection, we have to manipulate the elements manually. But for Enumeration, it will automatically manipulates the elements.
There are lot of examples in the net with other collections.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Probably I think you need some explanation regarding Enumeration, you might have done some coding with Iterator. Enumeration is similar to that Iterator both have purpose of getting each value in the Collection. Just check the below code and the result you will get idea.