Vector iterator

This commit is contained in:
mherbaghinyan 2018-12-21 12:19:09 +04:00
parent c52862fdd4
commit 64b205a6ce
1 changed files with 6 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package com.baeldung.java.list; package com.baeldung.java.list;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
public class VectorExample { public class VectorExample {
@ -16,6 +17,11 @@ public class VectorExample {
while(e.hasMoreElements()){ while(e.hasMoreElements()){
System.out.println(e.nextElement()); System.out.println(e.nextElement());
} }
Iterator<String> iterator = vector.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
}
} }
} }