List of usage examples for java.util Vector add
public synchronized boolean add(E e)
From source file:Main.java
public static void main(String[] args) { Vector<String> v1 = new Vector<String>(); v1.add("1"); v1.add("2");/*from w ww . j av a 2s.co m*/ v1.add("3"); Vector<String> v2 = new Vector<String>(); v2.add("One"); v2.add("Two"); v2.add("Three"); v2.add("Four"); v2.add("Five"); System.out.println(v2); Collections.copy(v2, v1); System.out.println(v2); }
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); }/*from w ww . ja v a 2 s.co m*/ System.out.println(v); }
From source file:Main.java
public static void main(String[] args) { Vector<String> v = new Vector<String>(); v.add("1"); v.add("2");//from w w w. ja va2 s . co m v.add("3"); ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("One"); arrayList.add("Two"); arrayList.add("Three"); arrayList.add("Four"); arrayList.add("Five"); System.out.println(arrayList); Collections.copy(arrayList, v); System.out.println(arrayList); }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("1"); arrayList.add("2"); arrayList.add("3"); Vector<String> v = new Vector<String>(); v.add("4"); v.add("5");/*from w w w . j ava 2 s .c om*/ // append all elements of Vector to ArrayList arrayList.addAll(v); for (String str : arrayList) System.out.println(str); }
From source file:Main.java
public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); vec.add(4); vec.add(3);/*from w ww . ja v a2s .c o m*/ vec.add(2); vec.add(1); // adding elements into the enumeration Enumeration e = vec.elements(); // let us print all the elements available in enumeration System.out.println("Numbers in the enumeration are :- "); while (e.hasMoreElements()) { System.out.println("Number = " + e.nextElement()); } }
From source file:Main.java
public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); vec.add(4); vec.add(3);//from ww w. j ava 2 s.c o m vec.add(2); vec.add(1); // let us print the size of the vector System.out.println("Size of the vector after addition :" + vec.size()); System.out.println(vec); // let us clear the vector vec.clear(); // let us print the size of the vector System.out.println("Size of the vector after clearing :" + vec.size()); }
From source file:TreeNodeRemove.java
public static void main(String[] argv) { Vector<String> v = new Vector<String>(); v.add("a"); v.add("b");/*from w w w. ja v a 2 s. co m*/ v.add("c"); JTree tree = new JTree(v); DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); int startRow = 0; String prefix = "b"; TreePath path = tree.getNextMatch(prefix, startRow, Position.Bias.Forward); MutableTreeNode node = (MutableTreeNode) path.getLastPathComponent(); model.removeNodeFromParent(node); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("1"); arrayList.add("2"); arrayList.add("3"); arrayList.add("4"); arrayList.add("5"); Vector<String> v = new Vector<String>(); v.add("A"); v.add("B");/*w ww .j a v a 2 s . c o m*/ v.add("D"); v.add("E"); v.add("F"); v.add("G"); v.add("H"); System.out.println(v); Collections.copy(v, arrayList); System.out.println(v); }
From source file:SortWithCollationKeys.java
public static void main(String[] args) { Vector<String> list = new Vector<String>(); list.add("m"); list.add("c"); list.add("e"); list.add("c"); Collator collate = Collator.getInstance(); CollationKey[] keys = new CollationKey[list.size()]; for (int k = 0; k < list.size(); k++) keys[k] = collate.getCollationKey((String) list.elementAt(k)); CollationKey tmp;/*from w w w. j a va 2s . c o m*/ for (int i = 0; i < keys.length; i++) { for (int j = i + 1; j < keys.length; j++) { if (keys[i].compareTo(keys[j]) > 0) { tmp = keys[i]; keys[i] = keys[j]; keys[j] = tmp; } } } for (int l = 0; l < keys.length; l++) { System.out.println(keys[l].getSourceString()); } }
From source file:MainClass.java
public static void main(String args[]) { Vector v = new Vector(); for (int i = 0, n = members.length; i < n; i++) { v.add(members[i]); }//from w w w . j a v a 2s . c om System.out.println(v); System.out.println(v.lastIndexOf("I")); }