In this segment of tutorial we will learn about the Vector class and its use with the Iterator interface.Then We will create an example to print the content of the a Vector.
In this segment of tutorial we will learn about the Vector class and its use with the Iterator interface.Then We will create an example to print the content of the a Vector.
import java.util.Iterator; import java.util.Vector; public class vector1 { public static void main(String[] args) { Vector v = new Vector(); String tree[] = { "olive", "oak", "grass", "mango" }; for (String s : tree) { v.add(s); } Iterator it = v.iterator(); for (; it.hasNext();) System.out.println(it.next()); } }
Output
olive oak grass mango