Example usage for java.util Vector get

List of usage examples for java.util Vector get

Introduction

In this page you can find the example usage for java.util Vector get.

Prototype

public synchronized E get(int index) 

Source Link

Document

Returns the element at the specified position in this Vector.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    Vector v = new Vector();
    v.add("Hello");
    String s = (String) v.get(0);
    System.out.println(s);//from  w w  w  .  j a  va2 s  . c o m
}

From source file:MainClass.java

public static void main(String args[]) {
    Vector v = new Vector();
    v.add("A");//from  www  . java  2s  .  c  o m
    v.add("B");

    Vector outter = new Vector();
    outter.add(v);

    String s = (String) ((Vector) outter.get(0)).get(0);
    System.out.println(s);
}

From source file:Main.java

public static void main(String args[]) {
    Vector<String> v = new Vector<String>();
    v.add("Hello");
    v.add("Hello");
    String s = v.get(0);
    System.out.println(s);/*from w w  w  . j a v  a 2  s.  c om*/
}

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 w w w. ja  v a2  s  .  c  o m
    }

}

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

    vec.add(4);/*from w  w  w  . jav  a2 s .  c  o  m*/
    vec.add(3);
    vec.add(2);
    vec.add(1);

    // let us get the 3rd element of the vector
    System.out.println("Third element is :" + vec.get(3));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);
    table.setAutoCreateColumnsFromModel(false);

    boolean ascending = false;
    Vector data = model.getDataVector();
    Object[] colData = new Object[model.getRowCount()];

    for (int i = 0; i < colData.length; i++) {
        colData[i] = ((Vector) data.get(i)).get(0);
    }/*from w  w  w .j a v  a2s .co m*/
    Arrays.sort(colData, new ColumnSorter());
    for (int i = 0; i < colData.length; i++) {
        ((Vector) data.get(i)).set(0, colData[i]);
    }
    model.fireTableStructureChanged();
}

From source file:Main.java

public static void main(String[] args) {

    Vector v = new Vector();

    v.add("1");/*from  ww  w  . ja va 2s . 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));
    }//  www.  j  ava2s.  co m

    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[] 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);

    int mColIndex = 0;
    List colData = new ArrayList(table.getRowCount());
    for (int i = 0; i < table.getRowCount(); i++) {
        row = (Vector) data.elementAt(i);
        colData.add(row.get(mColIndex));
    }/* ww  w. j  a va 2  s.c o m*/

    // Append a new column with copied data
    model.addColumn("Col3", colData.toArray());

    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:com.benasmussen.tools.testeditor.ExtractorCLI.java

public static void main(String[] args) throws Exception {
    HelpFormatter formatter = new HelpFormatter();

    // cli options
    Options options = new Options();
    options.addOption(CMD_OPT_INPUT, true, "Input file");
    // options.addOption(CMD_OPT_OUTPUT, true, "Output file");

    try {//  w  ww.  j  a v  a 2 s .  c o  m

        // evaluate command line options
        CommandLineParser parser = new GnuParser();
        CommandLine cmd = parser.parse(options, args);

        if (cmd.hasOption(CMD_OPT_INPUT)) {
            // option value
            String optionValue = cmd.getOptionValue(CMD_OPT_INPUT);

            // input file
            File inputFile = new File(optionValue);

            // id extractor
            IdExtractor idExtractor = new IdExtractor(inputFile);
            Vector<Vector> data = idExtractor.parse();

            // // TODO implement output folder
            // if (cmd.hasOption(CMD_OPT_OUTPUT))
            // {
            // // file output
            // throw new Exception("Not implemented");
            // }
            // else
            // {
            // console output
            System.out.println("Id;Value");
            for (Vector vector : data) {
                StringBuilder sb = new StringBuilder();
                if (vector.size() >= 1) {
                    sb.append(vector.get(0));
                }
                sb.append(";");
                if (vector.size() >= 2) {
                    sb.append(vector.get(1));
                }
                System.out.println(sb.toString());
            }
            // }
        } else {
            throw new IllegalArgumentException();
        }

    } catch (ParseException e) {
        formatter.printHelp("ExtractorCLI", options);
    } catch (IllegalArgumentException e) {
        formatter.printHelp("ExtractorCLI", options);
    }
}