Click here to watch in Youtube :
https://www.youtube.com/watch?v=NyraFk5FXUk&list=UUhwKlOVR041tngjerWxVccw
VectorExample.java
Output
https://www.youtube.com/watch?v=NyraFk5FXUk&list=UUhwKlOVR041tngjerWxVccw
VectorExample.java
import java.util.Iterator; import java.util.Vector; /* * Example of Iterator remove() method. */ public class VectorExample { public static void main( String[] args ) { Vector<String> vector = new Vector<String>(); vector.add("Dave"); vector.add("Peter"); vector.add("Phil"); System.out.println("vector : " + vector + "\n"); Iterator<String> iterator = vector.iterator(); while( iterator.hasNext() ) { iterator.next(); /* * Removes from the list the last element that was returned by * next() */ iterator.remove(); } System.out.println("vector : " + vector + "\n"); } }
vector : [Dave, Peter, Phil] vector : []
https://sites.google.com/site/javaee4321/java-collections/VectorDemoIteratorRemove.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment