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 isEmptyList(ArrayList arrayList) {
    return (arrayList == null || arrayList.size() <= 0);
}

From source file:Main.java

public static ArrayList<Integer> resetIncrementalList(ArrayList<Integer> list) {
    for (int i = 0; i < list.size(); i++) {
        if (i >= 2) {
            list.set(i, list.get(i) + list.get(i - 2));
        }/* w ww.  j  a v  a2  s. c o  m*/
    }
    return list;
}

From source file:Main.java

static public int[] toIntArray(ArrayList list) {
    int[] result = new int[list.size()];

    for (int i = 0; i < list.size(); i++) {
        Number n = (Number) list.get(i);
        result[i] = n.intValue();/*from w  ww. j a v a2 s.  co m*/
    }

    return result;
}

From source file:Main.java

private static int[] toIntArray(ArrayList<Integer> arrayList) {
    int[] ret = new int[arrayList.size()];
    for (int i = 0; i < ret.length; i++) {
        ret[i] = arrayList.get(i);//  w w  w .j  a v a 2s . com
    }
    return ret;
}

From source file:Main.java

public static String[] trans(ArrayList<String> als) {
    String[] sa = new String[als.size()];
    als.toArray(sa);//from   ww  w  . j  a v a  2  s .c  o  m
    return sa;
}

From source file:Main.java

public static String[] toStringArray(ArrayList<String> array) {
    String arr[] = new String[array.size()];

    for (int i = 0; i < array.size(); i++) {
        arr[i] = array.get(i);//  w  w w  .  j a  va 2 s  . c o m
    }

    return arr;
}

From source file:Main.java

/**
 * create new Array and copy from {@code src} to it. no effect to
 * {@code src}./*  w w w.  j a  v  a  2  s.c  o m*/
 */
static public long[] new_array_from(ArrayList<Long> src) {
    final long[] dest = new long[src.size()];
    for (int i = 0; i < src.size(); ++i) {
        dest[i] = src.get(i).longValue();
    }
    return dest;
}

From source file:Main.java

static long getAvarageValue(ArrayList<Long> times) {
    long num = times.size();
    if (num == 0)
        return 0;
    long timeSum = 0;
    for (long time : times)
        timeSum += time;/* w w w. j a  v a 2 s. c om*/
    long avgTime = timeSum / num;
    return avgTime;
}

From source file:Main.java

public static Object[] toObjectArray(ArrayList<Object> array) {
    Object arr[] = new Object[array.size()];

    for (int i = 0; i < array.size(); i++) {
        arr[i] = array.get(i);/* w w w  .j a  v  a  2  s  .  c o m*/
    }

    return arr;
}

From source file:Main.java

public static int[] toIntArray(ArrayList<Integer> arraylist) {
    int[] tmp = new int[arraylist.size()];
    int i = 0;//from  w ww  .j a  va 2s .c  o m
    for (int f : arraylist) {
        tmp[i] = f;
        i++;
    }
    return tmp;
}