This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I've got a simple program that processes all the elements of a Vector using an Enumeration. Since I am only USING the Enumeration interface and not IMPLEMENTing it, where EXACTLY are the abstract methods of the Enumeration interface "hasMoreElements()" and "nextElement()" implemented? I've tried looking through the docmentation, and I can't find where the actual implementation of the methods occur. ?!? Thanks. pm
if you write something like: System.out.println( new Vector().elements().getClass() ); the class name of the Enumeration will be displayed. In this case, it is: java.util.Vector$1. What this tells you is that the implementation is an anonymous class declared within Vector. A quick peek at the source of Vector.elements() reveals this to be the case.
Two notes: 1. Vector shouldn't be used. It's an old class kept around for backward compatibility. In many cases, an ArrayList is a good replacement. 2. I don't remember the reasons off hand, but folks recommend using an Iterator instead of an Enumeration.