List of usage examples for java.util Vector size
public synchronized int size()
From source file:MainClass.java
public static void main(String args[]) { // initial size is 3, increment is 2 Vector<Integer> v = new Vector<Integer>(3, 2); System.out.println("Initial size: " + v.size()); System.out.println("Initial capacity: " + v.capacity()); v.addElement(1);//from w w w. j a v a 2s. c om v.addElement(2); System.out.println("First element: " + v.firstElement()); System.out.println("Last element: " + v.lastElement()); if (v.contains(3)) System.out.println("Vector contains 3."); }
From source file:edu.ucsd.ccdb.cil.xml2json.XML2JsonDriver.java
public static void main(String[] args) throws Exception { boolean debug = false; long debugID = 29; XML2JsonUtil xutil = new XML2JsonUtil(); CCDBXMLResource xmlResource = new CCDBXMLResource(); HashMap<String, String> xmlMap = xmlResource.getXMLPaths(); DBUtil dbutil = new DBUtil(); Vector<Long> vIDs = dbutil.getCCDBPublicIDs(); for (int i = 0; i < vIDs.size(); i++) { long id = vIDs.get(i); if (!debug) { System.out.println("-----Working on:" + id); String path = xmlMap.get(id + ""); //System.out.println(path); String xml = xmlResource.getXMLContent(new File(path)); String json = xutil.xml2Json(xml); File f = new File(Constants.jsonOutputFolder2 + "/" + id + ".json"); xutil.outputStringToFile(f, json); } else if (debugID == id) { System.out.println("-----Working on:" + id); String path = xmlMap.get(id + ""); //System.out.println(path); String xml = xmlResource.getXMLContent(new File(path)); String json = xutil.xml2Json(xml); File f = new File(Constants.jsonOutputFolder2 + "/" + id + ".json"); xutil.outputStringToFile(f, json); }/*from ww w .j a v a 2 s . co m*/ } }
From source file:Main.java
public static void main(String[] args) { Vector<String> v = new Vector<String>(); v.add("1");/*from ww w. j a v a 2s . c om*/ v.add("2"); v.add("3"); System.out.println(v.size()); v.clear(); v.removeAllElements(); System.out.println(v.size()); }
From source file:Main.java
public static void main(String args[]) { Vector<String> v1 = new Vector<String>(); v1.add("A");//from ww w.j a v a 2s . c o m v1.add("B"); v1.add("C"); String array[] = new String[v1.size()]; v1.copyInto(array); for (int i = 0; i < array.length; i++) { System.out.println(array[i]); } }
From source file:MainClass.java
public static void main(String args[]) { Vector v = new Vector(); for (int i = 0; i < 5; i++) { v.addElement(new Double(5)); }/*from w w w . j a va 2s.c om*/ for (int i = v.size() - 1; i >= 0; i--) { System.out.print(v.elementAt(i) + " "); } }
From source file:Main.java
public static void main(String[] args) { Vector vec = new Vector(4); vec.add(4);/*from w w w. j av a 2s.co m*/ vec.add(3); vec.add(2); vec.add(1); System.out.println("Size of the vector: " + vec.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 ww w. j a v a 2 s . c o 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);/* www .j a v a 2 s . c o m*/ } 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(); v.add("1");/*from www.j a v a 2 s.c o m*/ v.add("3"); v.add("5"); v.add("2"); v.add("4"); Collections.sort(v); for (int i = 0; i < v.size(); i++) System.out.println(v.get(i)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); model.addColumn("Col1"); model.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); Vector data = model.getDataVector(); Vector row = (Vector) data.elementAt(1); // Overwrite the first row with the copy Vector firstRow = (Vector) data.elementAt(0); for (int i = 0; i < row.size(); i++) { firstRow.set(i, row.get(i));/*w w w . j av a2 s. com*/ } JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }