Example usage for java.util ArrayList size

List of usage examples for java.util ArrayList size

Introduction

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

Prototype

int size

To view the source code for java.util ArrayList size.

Click Source Link

Document

The size of the ArrayList (the number of elements it contains).

Usage

From source file:Main.java

public static boolean checkListSize(ArrayList<String> list) {
    return (list != null && list.size() > 0) ? true : false;
}

From source file:Main.java

public static boolean isArrayListEmpty(ArrayList arrayList) {
    return arrayList == null || arrayList.size() == 0;
}

From source file:Main.java

public static void removeElementsFromIndexToEnd(ArrayList list, int index) {
    for (int i = list.size() - 1; i >= index; i--)
        list.remove(i);//from w  w w  . j  a  v  a2 s  .  c  o  m
}

From source file:Main.java

public static double[][] toArray1(ArrayList<Double> a) {
    int dataDimen = a.size();
    double[][] res = new double[1][dataDimen];

    for (int i = 0; i < dataDimen; i++) {
        res[1][i] = a.get(i);//from w  w w.  jav a2 s  . co  m
    }

    return res;
}

From source file:Main.java

public final static <T> T getLast(ArrayList<T> list) {
    if (list != null && list.size() > 0) {
        return list.get(list.size() - 1);
    }/*from  ww  w.  j a v  a2  s .c  o  m*/
    return null;
}

From source file:Main.java

/**
 * Returns the last element of an array list.
 * Returns null if list is empty or null
 * //from   w w  w  . j a  va 2s.  c  om
 * @param list the ArrayList to search through
 * @return List the resulting element
 */

public static Object getLastElementOfArrayList(ArrayList list) {
    if (list != null || list.size() >= 0) {
        return list.get(list.size() - 1);
    }
    return null;
}

From source file:Main.java

public static <E> void removeDuplicate(ArrayList<E> list) {
    for (int i = 0; i < list.size() - 1; i++) {
        for (int j = list.size() - 1; j > i; j--) {
            if (list.get(j).equals(list.get(i))) {
                list.remove(j);//from  www . ja  v a2 s.  c om
            }
        }
    }
}

From source file:Main.java

public static <T> boolean isArrayListNull(ArrayList<T> listData) {
    if (listData != null && listData.size() != 0) {
        return false;
    }/*from  www. j a v a2s . c  o  m*/
    return true;
}

From source file:Main.java

/**
 *  Print/*from w  w w . j av  a 2s.  com*/
 * */
public static void print(ArrayList tokens) {
    for (int i = 0; i < tokens.size(); i++) {
        System.out.print(tokens.get(i) + " ");
    }
    System.out.print("\n");
}

From source file:Main.java

/**
 * It removes the first character of all the elements of the input ArrayList<String>
 * @param ar input array to be modified//from  w  w  w. j a v a 2s .  co  m
 * @return the input array without the first character '/t'
 */
public static ArrayList<String> extractT(ArrayList<String> ar) {
    for (int i = 0; i < ar.size(); i++) {
        ar.set(i, ar.get(i).substring(1));
    }

    return ar;
}