Java examples for Collection Framework:Vector
How to swap elements of Java Vector object using swap method of Collections class.
import java.util.Vector; import java.util.Collections; public class Main { public static void main(String[] args) { Vector v = new Vector(); v.add("1");/*from ww w. j a va2 s. co m*/ v.add("2"); v.add("3"); v.add("4"); v.add("5"); System.out.println("Before swaping, Vector contains : " + v); Collections.swap(v,0,4); System.out.println("After swaping, Vector contains : " + v); } }