Click here to watch in Youtube :
https://www.youtube.com/watch?v=8ANkcxyx7Gs&list=UUhwKlOVR041tngjerWxVccw
VectorExample.java
Output
https://www.youtube.com/watch?v=8ANkcxyx7Gs&list=UUhwKlOVR041tngjerWxVccw
VectorExample.java
import java.util.Vector; /* * Example of set(int index, E element) method. */ public class VectorExample { public static void main( String[] args ) { Vector<Integer> vector = new Vector<Integer>(); vector.add(20); vector.add(30); vector.add(40); vector.add(50); System.out.println("vector : " + vector + "\n"); /* * Replaces the element at the specified position in this Vector with * the specified element. */ Integer replacedElement = vector.set(2, 1000); System.out.println("replacedElement : " + replacedElement); System.out.println("vector : " + vector + "\n"); } }
vector : [20, 30, 40, 50] replacedElement : 40 vector : [20, 30, 1000, 50]
https://sites.google.com/site/javaee4321/java-collections/VectorDemoReplace.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment