Replace All Elements Of Vector - Java Collection Framework

Java examples for Collection Framework:Vector

Description

Replace All Elements Of Vector

Demo Code

 
import java.util.Vector;
import java.util.Collections;
 
public class Main {
 
  public static void main(String[] args) {
    Vector v = new Vector();
   /*  w  w  w  . j  av  a2s .c  o  m*/
    v.add("A");
    v.add("B");
    v.add("D");
 
    System.out.println("Before replacement, Vector contains : " + v);
   
    Collections.fill(v,"REPLACED");
   
    System.out.println("After replacement, Vector contains : " + v);
 
  }
}
 

Result


Related Tutorials