List of usage examples for java.util Vector Vector
public Vector()
From source file:FindVector.java
public static void main(String args[]) { String data[] = { "Java", "Source", "and", "Support", "." }; Vector v = new Vector(); for (int i = 0, n = data.length; i < n; i++) { v.add(data[i]);/* w w w . ja v a 2 s . co m*/ } System.out.println(v); System.out.println("Contains Java?: " + v.contains("Java")); System.out.println("Contains Java2s?: " + v.contains("Java2s")); System.out.println("Where's and?: " + v.indexOf("and")); System.out.println("Where's Source?: " + v.indexOf("Source")); System.out.println("Where's Java from end?: " + v.lastIndexOf("Java")); }
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 2 s .c o m } System.out.println(v); System.out.println(v.lastIndexOf("I")); }
From source file:Main.java
public static void main(String[] args) { Vector<String> v = new Vector<String>(); v.add("1");//from www.j a v a 2s . c om v.add("2"); 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) { // create vector List<String> vector = new Vector<String>(); // populate the vector vector.add("R"); vector.add("B"); vector.add("R"); vector.add("java2s.com"); System.out.println("Initial values are :" + vector); Collections.replaceAll(vector, "R", "java2s.com"); System.out.println("Value after replace :" + vector); }
From source file:Main.java
public static void main(String[] args) { Vector<String> v = new Vector<String>(); v.add("A");//from w w w . ja v a2 s. c om v.add("B"); v.add("D"); v.add("E"); v.add("F"); System.out.println(v); Enumeration<String> e = v.elements(); ArrayList<String> aList = Collections.list(e); System.out.println(aList); }
From source file:MainClass.java
public static void main(String args[]) { Vector vector = new Vector(); vector.addElement(new Integer(5)); vector.addElement(new Float(-14.14f)); vector.addElement(new String("Hello")); Enumeration e = vector.elements(); while (e.hasMoreElements()) { Object obj = e.nextElement(); System.out.println(obj);//from w w w . java2 s. com } }
From source file:Main.java
public static void main(String[] args) { Vector<String> v = new Vector<String>(); v.add("A");//w ww . j ava 2 s.c o m v.add("B"); v.add("D"); v.add("E"); v.add("F"); System.out.println(v); Enumeration e = v.elements(); ArrayList<String> aList = Collections.list(e); System.out.println(aList); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Vector v = new Vector(); v.add("a");//from w w w .j av a 2s .co m v.add("b"); v.add("c"); Collection col = v; Enumeration e = Collections.enumeration(col); for (; e.hasMoreElements();) { Object o = e.nextElement(); System.out.println(o); } }
From source file:Main.java
public static void main(String[] arguments) { String[] codes = { "alpha", "lambda", "gamma", "delta", "zeta" }; Vector list = new Vector(); for (int i = 0; i < codes.length; i++) { if (!list.contains(codes[i])) { list.add(codes[i]);//from ww w . j a va 2s . c om } } for (Iterator ite = list.iterator(); ite.hasNext();) { String output = (String) ite.next(); System.out.println(output); } }
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 v a 2 s.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()); } }