Example usage for java.util ArrayList get

List of usage examples for java.util ArrayList get

Introduction

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

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:com.cprassoc.solr.auth.util.CommandLineExecutor.java

public static int execChain(ArrayList<String> cmds) {
    int exitValue = -1;
    try {//from  w ww . j  a  v a  2 s . c o  m
        for (int i = 0; i < cmds.size(); i++) {
            exitValue = exec(cmds.get(i));
            if (exitValue > 0) {
                throw new IOException();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return exitValue;
}

From source file:Main.java

public static void printAccounts(ArrayList<String> accounts) {
    System.out.println("Here are the list of accounts possible:");
    for (int i = 0; i < accounts.size(); i++) {
        System.out.println((i + 1) + ": " + accounts.get(i));
    }// w  ww .j a v a  2s  . com
}

From source file:Main.java

/**
 * Implode/*w ww  .  ja  v a 2s  .  c  o  m*/
 * @param ids
 * @return 
 */
public static String convertToCommaDelimitedString(ArrayList<String> ids) {
    String out = "";
    for (int i = 0; i < ids.size(); i++) {
        if (i != 0) {
            out += "','";
        }
        out += ids.get(i).toString();
    }
    return "'" + out + "'";
}

From source file:Main.java

private static void moveCells(int width, int height, ArrayList<ArrayList<Integer>> source,
        int[][] destination) {
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            destination[x][y] = source.get(y).get(x);
        }/*from  w w w .  j a v a 2s  .c o m*/
    }
}

From source file:mongodb.MongoUtils.java

public static Document ListToDocument(ArrayList<Object> liste, ArrayList<Colonne> colonnes) {
    Document resultat = new Document();
    for (int i = 0; i < colonnes.size(); i++) {
        construct(resultat, colonnes.get(i).getNom(), liste.get(i));
    }/*from w ww .j  a v a 2  s  .  c  o  m*/

    return resultat;
}

From source file:Main.java

public static String getTextElementValue(String elementName, Element parentElement, boolean showEmptyAsNull) {
    ArrayList<Node> childNodesWithTagName = getChildNodesWithTagName(elementName, parentElement);

    if (childNodesWithTagName.size() > 0) {
        Node childNode = childNodesWithTagName.get(0);
        String text = childNode.getFirstChild().getNodeValue().trim();

        return text.equals("") && showEmptyAsNull ? null : text;
    }//  w  ww  .j  ava2s  .c om

    return null;
}

From source file:Main.java

public static void sortAsDouble(ArrayList<String> mylist) {
    String min = new String();
    int len = mylist.size();
    for (int i = 0; i < len; i++) {
        min = mylist.get(i);
        for (int j = i + 1; j < len; j++) {
            if (compareAsDouble(min, mylist.get(j)) == 1) {
                mylist.set(i, mylist.get(j));
                mylist.set(j, min);/*  w w  w  . java 2  s. c  o  m*/
                min = mylist.get(i);
            }
        }
    }
}

From source file:Main.java

public static String emailListToEmailCSV(ArrayList<String> emails) {
    String retStr = "";
    for (int i = 0; i < emails.size(); i++) {
        if (i > 0) {
            retStr += ",";
        }//from  w ww  .j ava2s . c o m
        retStr += emails.get(i);
    }
    return retStr;
}

From source file:Main.java

public static String joinArrayList(ArrayList<String> args, String delimiter, int startingIndex) {
    StringBuilder s = new StringBuilder();
    for (int i = startingIndex; i < args.size(); i++) {
        s.append(args.get(i));
        if (!(i + 1 >= args.size())) {
            s.append(delimiter);//from  w  ww.  ja v a  2  s .  c o  m
        }
    }
    return s.toString();
}

From source file:Main.java

/**
 * This is based on bit shifting (using base128()).
 * Returns array of bytes./*from w  w  w  .  j  a  v  a 2 s .  c o  m*/
 * @param val
 * @return
 */
public static byte[] toBase_128(BigInteger val) {
    ArrayList<Integer> al = base128(val);
    byte[] result = new byte[al.size()];
    for (int k = 0; k < result.length; k++)
        result[k] = al.get(k).byteValue();
    ;
    return result;
}