Click here to watch in Youtube :
https://www.youtube.com/watch?v=I3QcdDlMY-Y&list=UUhwKlOVR041tngjerWxVccw
import java.util.Vector; /* * Example of remove(int index) method. */ public class VectorExample { public static void main( String[] args ) { Vector<Integer> vector = new Vector<Integer>(); vector.add(100); vector.add(40); vector.add(30); vector.add(50); System.out.println("vector : " + vector + "\n"); /* * Removes the element at the specified position in this Vector. Shifts * any subsequent elements to the left (subtracts one from their * indices). Returns the element that was removed from the Vector. */ Integer removedElement = vector.remove(1); System.out.println("removedElement : " + removedElement); System.out.println("vector : " + vector + "\n"); } }
vector : [100, 40, 30, 50] removedElement : 40 vector : [100, 30, 50]
https://sites.google.com/site/javaee4321/java-collections/VectorDemoRemoveIndex.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment