Monday, 25 May 2015

Reverse order of all elements of Vector

import java.util.Collections;
import java.util.Vector;

public class ReverseAllelement {

    public static void main(String[] args) {
        Vector<String> vector = new Vector<String>();
        //add element in vector
        // print vector
        System.out.println("Before reverse Vector = "+vector);
         * Reverses the order of the elements in the
         * specified list. This method runs in linear time.
      System.out.println("After reverse Vector = "+vector);


Before reverse Vector = [cricket, hockey, football, tennish]

After reverse Vector = [tennish, football, hockey, cricket]

No comments:

Post a Comment