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) { // 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); secondvec.add(6);//from w w w . j a v a 2s . c o m 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[] argv) { Vector rowData = new Vector(); for (int i = 0; i < 1; i++) { Vector colData = new Vector(Arrays.asList("qq")); rowData.add(colData); }/*from w w w. j av a 2s . c o m*/ String[] columnNames = { "a" }; Vector columnNamesV = new Vector(Arrays.asList(columnNames)); JTable table = new JTable(rowData, columnNamesV); JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { Vector<Integer> firstvec = new Vector<Integer>(4); Vector<Integer> secondvec = new Vector<Integer>(4); // additing in firstvec firstvec.add(4); firstvec.add(3);// w w w . j ava 2s . c o m firstvec.add(2); // additing in secondvec secondvec.add(4); secondvec.add(3); secondvec.add(2); // let us print all the elements available in vector System.out.println("Testing equality of firstvec and secondvec :" + firstvec.equals(secondvec)); }
From source file:VectorBenchmark1.java
public static void main(String[] args) { Vector v = new Vector(); long start = System.currentTimeMillis(); for (int i = 0; i < MaxSize; i++) v.add(new Integer(i)); long end = System.currentTimeMillis(); System.out.println("Allocating vector elements: " + (end - start) + " milliseconds"); Integer[] integerArray = new Integer[1]; start = System.currentTimeMillis(); for (int i = 0; i < MaxSize; i++) { if (i >= integerArray.length) { Integer[] b = new Integer[i * 2]; System.arraycopy(integerArray, 0, b, 0, integerArray.length); integerArray = b;//from www . j a v a 2 s .c o m } integerArray[i] = new Integer(i); } end = System.currentTimeMillis(); System.out.println("Allocating array elements: " + (end - start) + " milliseconds"); start = System.currentTimeMillis(); for (int j = 0; j < NTRIES; j++) for (int i = 0; i < MaxSize; i++) { Integer r = (Integer) v.get(i); v.set(i, new Integer(r.intValue() + 1)); } end = System.currentTimeMillis(); System.out.println("Accessing vector elements: " + (end - start) + " milliseconds"); start = System.currentTimeMillis(); for (int j = 0; j < NTRIES; j++) for (int i = 0; i < MaxSize; i++) { Integer r = integerArray[i]; integerArray[i] = new Integer(r.intValue() + 1); } end = System.currentTimeMillis(); System.out.println("Accessing array elements: " + (end - start) + " milliseconds"); }
From source file:Main.java
public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); Vector<Integer> vectest = new Vector<Integer>(4); Vector<Integer> vecdiff = new Vector<Integer>(4); vec.add(4); vec.add(3);//w w w .j a v a2 s . co m vec.add(2); vectest.add(4); vectest.add(3); vectest.add(2); vecdiff.add(4); vecdiff.add(3); vecdiff.add(12); // let us check vec and vectest System.out.println(vectest.containsAll(vec)); // let us check vec and vecdiff System.out.println(vecdiff.containsAll(vec)); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<Vector<String>> rowData = new Vector<Vector<String>>(); Vector<String> columnName = new Vector<String>(Arrays.asList("Column 1")); for (int i = 0; i < 2000; i++) { rowData.add(new Vector<String>(Arrays.asList(Integer.toString(i)))); }// ww w. ja va2s . c om JTable table = new JTable(rowData, columnName); JScrollPane scrollPane = new JScrollPane(table); JScrollBar vertical = scrollPane.getVerticalScrollBar(); vertical.setPreferredSize(new Dimension(0, 0)); f.add(scrollPane); f.pack(); f.setVisible(true); JViewport view = scrollPane.getViewport(); Component[] components = view.getComponents(); for (int i1 = 0; i1 < components.length; i1++) { if (components[i1] instanceof JTable) { System.out.println("got"); } } }
From source file:Main.java
public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); Integer anArray[] = new Integer[4]; anArray[0] = 100;//from w w w. j a va 2 s.co m anArray[1] = 100; anArray[2] = 100; anArray[3] = 100; vec.add(4); vec.add(3); vec.add(2); vec.add(1); for (Integer number : anArray) { System.out.println("Number = " + number); } // copy into the array vec.copyInto(anArray); for (Integer number : anArray) { System.out.println("Number = " + number); } }
From source file:edu.jhu.pha.vospace.node.NodePath.java
public static final void main(String[] s) { try {/*from w w w. j ava2s . com*/ NodePath sres1 = new NodePath("/a/"); System.out.println(sres1.getParentRelativePath(new NodePath("/a/b/c"))); } catch (Exception ex) { ex.printStackTrace(); } System.exit(1); Vector<String> strs = new Vector<String>(); strs.add(""); strs.add("/"); strs.add("cont1"); strs.add("/cont1"); strs.add("/cont1/"); strs.add("/cont1/file1"); strs.add("cont1/file1"); strs.add("cont1/dir1/"); strs.add("cont1/dir1/file1"); strs.add("cont1/dir1/dir2/file1"); strs.add("cont1/dir1/dir2/dir3/"); for (String sss : strs) { try { NodePath sres1 = new NodePath(sss); System.out.println(sss + ": (" + sres1.getContainerName() + "|" + sres1.getNodeStoragePath() + "|" + sres1.getNodeOuterPath() + ");"); } catch (Exception ex) { ex.printStackTrace(); } } }
From source file:edu.duke.cabig.c3pr.domain.scheduler.runtime.job.CCTSNotificationMessageJob.java
public static void main(String[] args) { Vector v = new Vector(); v.add(new CCTSNotification()); System.out.println(v);/*from w w w . j a va2s . co m*/ byte[] b = SerializationUtils.serialize(v); Vector v2 = (Vector) SerializationUtils.deserialize(b); System.out.println(v2); }
From source file:com.intel.cosbench.driver.random.RangeIntGenerator.java
public static void main(String[] args) { final String pattern = "r(50,100)"; final int all = 5; int i = 0;//w w w.j a va2s .c o m Vector<TestThread> threads = new Vector<TestThread>(); RangeIntGenerator gen = RangeIntGenerator.parse(pattern); for (i = 0; i < all; i++) { TestThread thread = new TestThread(gen, i + 1, all); threads.add(thread); thread.start(); } try { for (i = 0; i < all; i++) { threads.elementAt(i).join(); } } catch (InterruptedException ie) { ie.printStackTrace(); } }