public
Enumeration<E> elements()
Returns
an enumeration of the components of this vector.
import java.util.*; class VectorElementElements{ public static void main(String args[]){ Vector<String> myVector; Enumeration<String> myEnum; myVector = new Vector<> (); /* Add Elements to myVector */ for(int i=1; i<6; i++) myVector.add("String " +i); myEnum = myVector.elements(); while(myEnum.hasMoreElements()){ System.out.println(myEnum.nextElement()); } } }
Output
String 1 String 2 String 3 String 4 String 5
No comments:
Post a Comment