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:Main.java

public static Node getNodeWithKey(Node parent, String key, String value) {
    HashSet<String> values = new HashSet<String>();
    values.add(value);// w  w w.  j a va  2 s  . c  om
    ArrayList<Node> nodes = getNodesWithKey(parent, key, values, false);
    if (nodes.size() < 1)
        return null;
    return nodes.get(0);
}

From source file:Main.java

/**
 * Joins the arraylist into a single string, combining them with commas.
 * @param list/*w ww .ja  v a 2s .  c o  m*/
 * @return
 */
public static String join(ArrayList<String> list) {
    String item = "";

    for (int i = 0; i < list.size(); i++) {
        if (i > 0)
            item += ",";

        item += list.get(i);
    }

    return item;
}

From source file:edu.illinois.cs.cogcomp.wsim.embedding.Embedding.java

public static double[] add(ArrayList<double[]> lis) {
    double[] sum = new double[lis.get(0).length];
    for (int i = 0; i < lis.size(); i++) {
        sum = add(sum, lis.get(i));//from   w w w  .j a v  a 2  s  .c  o  m
    }
    return sum;
}

From source file:Main.java

/**
 * Removes the given object from the list using reference equality, not equals()
 * @param list//from   ww  w .j a  va 2s . c om
 * @param object
 * @return
 */
public static <T> boolean removeByReference(ArrayList<T> list, T object) {
    if (list == null)
        return false;
    int size = list.size();
    for (int i = 0; i < size; i++) {
        if (list.get(i) == object) {
            list.remove(i);
            return true;
        }
    }
    return false;
}

From source file:Main.java

public static void printLeagues(ArrayList<String> leagues) {
    System.out.println("Here are the list of leagues possible:");
    for (int i = 0; i < leagues.size(); i++) {
        System.out.println((i + 1) + ": " + leagues.get(i));
    }//from w w  w.  j  a v a2  s .co  m
}

From source file:Main.java

/**
 * returns a P with the value of the specifed attribute of the specifed tags
 * //from  ww w .  j  ava2s .  c  o m
 * @param doc
 * @param strTagName
 * @param strAttribute
 * @return
 */
public static Properties getPropertiesFromArrayList(ArrayList<String> al) {

    Properties pr = new Properties();

    // cycles on all of them
    for (int i = 0; i < al.size(); i++) {

        pr.setProperty(al.get(i), "");
    }

    return pr;
}

From source file:Main.java

public static boolean getBoundaryLevel(Point bound) {
    if (mLevelSet == null)
        mLevelSet = mContext.getSharedPreferences(PREFER, Context.MODE_WORLD_READABLE).getStringSet(LEVELSET,
                null);//from   ww  w  . j a va 2s  .  c  o m
    if (mLevelSet != null) {
        ArrayList<String> array = Collections.list(Collections.enumeration(mLevelSet));
        Collections.sort(array, mComparator);
        bound.x = Integer.valueOf(array.get(0));
        bound.y = Integer.valueOf(array.get(array.size() - 1));
        return true;
    }
    return false;
}

From source file:com.jennifer.ui.util.StringUtil.java

public static String join(ArrayList<String> result, String splitter) {
    StringBuilder b = new StringBuilder();
    b.append(result.get(0));

    for (int i = 1, len = result.size(); i < len; i++) {
        b.append(splitter).append(result.get(i));
    }//from w  w w  .  j  av a  2  s  . c o m

    return b.toString().trim();
}

From source file:Main.java

@SuppressWarnings("rawtypes")
public static String implode(ArrayList ary, String delim) {
    String out = "";
    for (int i = 0; i < ary.size(); i++) {
        //if (ary.get(i)!=null) {
        out += (String) ary.get(i);
        if (i != ary.size() - 1) {
            out += delim;//from  w  w  w  . j a va  2 s  .c  o  m
        }

        //}
    }
    return out;
}

From source file:Main.java

private static void verifyArrayListIsSingleType(ArrayList arrayList) {
    for (int i = 1; i < arrayList.size(); i++) {
        if (!arrayList.get(i - 1).getClass().isInstance(arrayList.get(i))) {
            throw new IllegalArgumentException("Cannot pass array of multiple types via props");
        }/*from   w  w w . j ava  2s. c  o m*/
    }
}