List of usage examples for java.util Vector add
public void add(int index, E element)
From source file:Main.java
public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); vec.add(0, 4); vec.add(1, 3);//from w w w. j a va2 s . c o m vec.add(2, 2); vec.add(3, 1); for (Integer number : vec) { System.out.println("Index :" + vec.indexOf(number) + " Number: " + number); } // added new number 10 at 3rd position/index vec.add(3, 10); for (Integer number : vec) { System.out.println("Index :" + vec.indexOf(number) + " Number: " + number); } }
From source file:MainClass.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(0, i); }//from www . j ava 2s. co m System.out.println(v); v.setSize(3); System.out.println(v); }
From source file:Main.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(i, 0); }/*from ww w .j a v a 2s .c o m*/ System.out.println(v); v.clear(); System.out.println(v); }
From source file:Main.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(0, i); }/* w w w . j ava 2 s . c om*/ System.out.println(v); v.setSize(0); System.out.println(v); System.out.println(v.isEmpty()); }
From source file:MainClass.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(i, 0); }/*from w w w. j a v a2s . com*/ System.out.println(v.capacity()); System.out.println(v); v.clear(); System.out.println(v); System.out.println(v.capacity()); }
From source file:MainClass.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(0, i); }//from ww w.j av a2s. co m System.out.println(v); System.out.println(v.size()); for (int i = 0; i < 10; i++) { v.add(0, i); } System.out.println(v); System.out.println(v.size()); }
From source file:MainClass.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(0, i); }/*from w ww .j a v a2 s .c o m*/ System.out.println(v); Vector v2 = new Vector(5); for (int i = 0; i < 10; i++) { v2.add(0, i); } System.out.println(v2); System.out.println(v2.equals(v)); }
From source file:Main.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(0, i); }/* w w w. j a v a 2s.c o m*/ System.out.println(v.capacity()); System.out.println(v); v.remove(1); v.removeElementAt(2); System.out.println(v); System.out.println(v.capacity()); }
From source file:MainClass.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(0, i); }//from ww w. ja v a 2s .c om System.out.println(v); System.out.println(v.size()); v.ensureCapacity(40); for (int i = 0; i < 10; i++) { v.add(0, i); } System.out.println(v); System.out.println(v.size()); }
From source file:Main.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.add(0, i); }/*from w w w. j a v a 2s. c o m*/ System.out.println(v.capacity()); System.out.println(v); v.remove(new Integer(9)); v.removeElement(new Integer(2)); System.out.println(v); System.out.println(v.capacity()); }