List of usage examples for java.util Vector Vector
public Vector(Collection<? extends E> c)
From source file:Main.java
public static void main(String[] args) { Vector vec = new Vector(8); List sublist = new ArrayList(10); vec.add(4);// w w w. j av a2 s .co m vec.add(3); vec.add(2); vec.add(1); vec.add(6); vec.add(7); vec.add(9); vec.add(5); sublist = vec.subList(2, 6); System.out.println(sublist); }
From source file:MainClass.java
public static void main(String args[]) { Integer[] array = { 1, 2, 3, 4, 5 }; Vector<Integer> v = new Vector<Integer>(Arrays.asList(array)); System.out.println(v);//from w ww . j a va2 s . c o m }
From source file:Main.java
public static void main(String[] args) { // create an empty Vector vec with an initial capacity of 6 Vector vec = new Vector(6); vec.add(33);//from www .j a v a2 s . co m vec.add(34); vec.add(22); vec.add(11); vec.add(22); vec.add(12); // let us remove the 1st element System.out.println("Removed element: " + vec.remove((Integer) 22)); System.out.println(vec); }
From source file:Main.java
public static void main(String[] args) { // create two empty Vectors firstvec and secondvec Vector<Integer> firstvec = new Vector<Integer>(4); Vector<Integer> secondvec = new Vector<Integer>(4); // use add() method to add elements in the secondvec vector secondvec.add(5);/*ww w .j a va2 s . co m*/ secondvec.add(6); secondvec.add(7); secondvec.add(8); // use add() method to add elements in the firstvec vector firstvec.add(1); firstvec.add(2); firstvec.add(3); firstvec.add(4); // use addAll() method to add secondvec with firstvec vector firstvec.addAll(secondvec); // let us print all the elements available in vector firstvec vector System.out.println("Added numbers are :- "); System.out.println(firstvec); }
From source file:Main.java
public static void main(String[] args) { Collection<Integer> list = new ArrayList<Integer>(); list.add(9);//from w w w .j a v a2 s .co m Vector vec = new Vector(list); vec.add(4); vec.add(3); vec.add(2); vec.add(1); System.out.println(vec); }
From source file:CreateVector.java
public static void main(String args[]) { {/* w w w.j a v a 2 s . com*/ Vector v = new Vector(0); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); } { Vector v = new Vector(); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); v.addElement("Hello"); System.out.println(v.capacity()); } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Vector v = new Vector(3); v.add(new FileInputStream("/a/b")); v.add(new FileInputStream("yourfile.bar")); v.add(new FileInputStream("/yourfile.txt")); Enumeration e = v.elements(); SequenceInputStream sis = new SequenceInputStream(e); InputStreamReader isr = new InputStreamReader(sis); BufferedReader br = new BufferedReader(isr); String line;/* w ww.j a v a 2 s .c om*/ while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); }
From source file:Sequence.java
public static void main(String args[]) throws IOException { Vector v = new Vector(3); v.add(new FileInputStream("/etc/motd")); v.add(new FileInputStream("foo.bar")); v.add(new FileInputStream("/temp/john.txt")); Enumeration e = v.elements(); SequenceInputStream sis = new SequenceInputStream(e); InputStreamReader isr = new InputStreamReader(sis); BufferedReader br = new BufferedReader(isr); String line;//from w w w . j a v a 2 s. c om while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Vector v = new Vector(Arrays.asList("a", "b", "c")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(v);// w w w.ja va 2 s . c o m oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); Vector v2 = (Vector) ois.readObject(); Enumeration e = v.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }
From source file:SaveVector1.java
public static void main(String args[]) throws Exception { Vector v = new Vector(Arrays.asList(args)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(v);/*from ww w . j av a 2 s. c o m*/ oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); Vector v2 = (Vector) ois.readObject(); Enumeration e = v.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }