Reverse order of all elements of Vector - Java Collection Framework

Java examples for Collection Framework:Vector

Description

Reverse order of 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();
    v.add("A");/*from ww w. ja va  2 s  .  c o  m*/
    v.add("B");
    v.add("C");
    v.add("D");
    v.add("E");
   
    System.out.println("Before Reverse Order, Vector Contains : " + v);
   
    Collections.reverse(v);
   
    System.out.println("After Reverse Order, Vector Contains : " + v);
   
  }
}

Result


Related Tutorials