Click here to watch in Youtube :
https://www.youtube.com/watch?v=w1RbmUHl3B0&list=UUhwKlOVR041tngjerWxVccw
import java.util.Vector; /* * Example of insertElementAt(E obj, int index) method. */ public class VectorExample { public static void main( String[] args ) { Vector<Integer> vector = new Vector<>(); vector.add(10); vector.add(20); vector.add(30); vector.add(40); vector.add(50); System.out.println("vector : " + vector + "\n"); /* * Inserts the specified object as a component in this vector at the * specified index. Each component in this vector with an index greater * or equal to the specified index is shifted upward to have an index * one greater than the value it had previously. */ vector.insertElementAt(4000, 1); System.out.println("vector : " + vector + "\n"); } }
vector : [10, 20, 30, 40, 50] vector : [10, 4000, 20, 30, 40, 50]
https://sites.google.com/site/javaee4321/java-collections/VectorDemoInsertElementAt.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment