Caution

nextElement()

has the side-effect  of removing  the next element from the enumeration.

If you want to make several uses of the object, you should assign  the element to a variable:

while( e.hasMoreElements() )
  {
  Object next = e.nextElement();
    ...use next...
  }

 

Note:

nextElement() returns an Object  which may need to be cast  to its appropriate class.

 

Example

Convert a Vector containing String's into a Vector of Float's by parsing each String as a float.

 

To Next Slide To Previous Slide To Contents