This segment of tutorial illustrates about the Vector class and its use with the Iterator interface.We will create an example to print the content of the a Vector.
This segment of tutorial illustrates about the Vector class and its use with the Iterator interface.We will create an example to print the content of the a Vector.
import java.util.Iterator;
import java.util.Vector;
public class vector {
public static void main(String[] args) {
Vector v = new Vector();
String city[] = { "delhi", "hongkong", "dubai", "sanghai" };
for (String s : city) {
v.add(s);
}
Iterator it = v.iterator();
for (; it.hasNext();)
System.out.println(it.next());
}
}
Output
delhi hongkong dubai sanghai