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 String getCommaSeperatedString(ArrayList<String> stringArrayList) {
    StringBuilder stringBuilder = new StringBuilder();
    String sep = ", ";
    for (int i = 0; i < stringArrayList.size(); i++) {
        stringBuilder.append(stringArrayList.get(i));
        if (i != stringArrayList.size() - 1) {
            stringBuilder.append(sep);//from   w w w  .ja  v a  2 s .  c  o m
        }
    }
    return stringBuilder.toString();
}

From source file:Main.java

public static String getExSdCardPath() {
    if ("".equals(exSdCardPath)) {
        ArrayList<String> paths = (ArrayList<String>) getExtSDCardPaths();
        if (paths.size() != 0) {
            exSdCardPath = paths.get(0) + "/";
        } else {/*from  w w  w .  j a  v  a2 s  .c o m*/
            exSdCardPath = null;
        }
    }

    return exSdCardPath;
}

From source file:com.appassit.http.ApiRequestFactory.java

/**
 * GETurl/*w w w  . j av a 2  s.c  o m*/
 * 
 * @param url
 * @param params
 * @return
 */
private static String getGetRequestUrl(String url, ArrayList<BasicNameValuePair> params) {
    if (params == null || params.size() == 0) {
        return url;
    }
    StringBuilder builder = new StringBuilder();
    builder.append(url).append("?");
    for (BasicNameValuePair entry : params) {
        Object obj = entry.getValue();
        if (obj == null)
            continue;
        builder.append(entry.getName()).append("=").append(entry.getValue()).append("&");
    }
    builder.deleteCharAt(builder.length() - 1);
    return builder.toString();

}

From source file:Main.java

public static int indexOfItem(ArrayList<String> list, final String item) {
    if (item == null || list.isEmpty()) {
        return -1;
    }//from  w w  w.  ja va2s .com
    for (int i = 0; i < list.size(); i++) {
        if (item.equals(list.get(i))) {
            return i;
        }
    }
    return -1;
}

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));//  w  ww.j a  v  a2  s. c om
        if (!(i + 1 >= args.size())) {
            s.append(delimiter);
        }
    }
    return s.toString();
}

From source file:anslab2.Test.java

public static ArrayList sortData(ArrayList toSort, int dataType) {
    n = toSort.size();

    if (dataType == 1) {
        ArrayList<String> alphabetic = new ArrayList<String>();

        for (Object data : toSort) {
            ;//from  www .  j  a va 2  s  . c  o  m
            alphabetic.add(String.valueOf(data));
        }
        Collections.sort(alphabetic);
        labels = alphabetic;
        return alphabetic;
    } else if (dataType == 2) {
        ArrayList<Double> numeric = new ArrayList<Double>();

        for (Object data : toSort) {
            numeric.add(Double.valueOf(String.valueOf(data)));
        }
        Collections.sort(numeric);
        labelsD = numeric;
        return numeric;
    }

    else if (dataType == 3) {
        ArrayList<String> string = new ArrayList<String>();

        for (Object data : toSort) {
            string.add(String.valueOf(data));
        }
        Collections.sort(string);
        labels = string;
        return string;
    }
    return null;
}

From source file:Main.java

private static float[] toFloatArray(ArrayList<Float> arrayList) {
    float[] ret = new float[arrayList.size()];
    for (int i = 0; i < ret.length; i++) {
        ret[i] = arrayList.get(i);/*from w  w w  . j  a  v  a2 s . c  om*/
    }
    return ret;
}

From source file:br.edu.ufcg.supervisor.engine.Simulation.java

private static String getShortestPath(ArrayList<String> array) {
    if (array.size() == 0) {
        return "";
    }//from ww w  .j  a  v a 2  s.c om
    int minimo = array.get(0).split(".").length;
    int qtd;
    int indexMenorCaminho = 0;
    for (int i = 1; i < array.size(); i++) {
        qtd = array.get(i).split(".").length;
        if (qtd < minimo) {
            minimo = qtd;
            indexMenorCaminho = i;
        }
    }
    return array.get(indexMenorCaminho);
}

From source file:MonteCarloWindowLogic.java

static private void divideOnPairsAndConvertConvexHullIntoSeries(XYSeries[] seriesDestination,
        ArrayList<Point2D> convexHull) {
    for (int i = 1; i < convexHull.size(); i++) {
        seriesDestination[i - 1].add(convexHull.get(i - 1).getX(), convexHull.get(i - 1).getY());
        seriesDestination[i - 1].add(convexHull.get(i).getX(), convexHull.get(i).getY());
    }/*from w  w w .j  a v a  2  s .  co m*/
}

From source file:Main.java

public static ViewFlipper creativeFlipper(Context context, ArrayList<View> addView, int in_ani, int out_ani) {
    ViewFlipper flipper = creativeFlipper(context);
    for (int i = 0; i < addView.size(); i++)
        flipper.addView(addView.get(i));
    setAnimation(context, flipper, in_ani, out_ani);
    return flipper;
}