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 CharSequence[] toCharSequenceArray(ArrayList<String> strings) {
    CharSequence[] list = new CharSequence[strings.size()];
    for (int i = 0; i < strings.size(); ++i) {
        list[i] = strings.get(i);// ww  w  .j a  v  a 2s .com
    }
    return list;
}

From source file:Main.java

public static String toString(ArrayList<String> arrayList) {
    return toString(arrayList, 0, arrayList.size() - 1);
}

From source file:Main.java

/**
 * buildStringFromArray/*from   www  . j  ava2 s .  c  o m*/
 *
 * @param stringArray the String[] to convert
 * @param separator   the string separator
 * @return the separated string
 */
public static String buildStringFromArray(ArrayList<String> stringArray, String separator) {
    if (stringArray.size() > 0) {
        StringBuilder nameBuilder = new StringBuilder();
        for (String n : stringArray) {
            nameBuilder.append(n).append(separator);
        }
        nameBuilder.deleteCharAt(nameBuilder.length() - 1);
        return nameBuilder.toString();
    } else {
        return null;
    }
}

From source file:Main.java

public static String[] getOccupantsIdsArrayFromList(ArrayList<Integer> occupantsList) {
    String[] occupantsArray = new String[occupantsList.size()];
    for (int i = 0; i < occupantsList.size(); i++) {
        occupantsArray[i] = String.valueOf(occupantsList.get(i));
    }/*from  w w w . ja  v a2s. c  o  m*/
    return occupantsArray;
}

From source file:Main.java

public static long[] toArray(ArrayList<Long> src) {
    long[] res = new long[src.size()];
    for (int i = 0; i < src.size(); i++) {
        res[i] = src.get(i);/*  w  w  w . j  a  v  a2 s. com*/
    }
    return res;
}

From source file:Main.java

public static String getCharCountStringForSMS(String text) {
    SmsManager smsMan = SmsManager.getDefault();
    ArrayList<String> dividedMessages = smsMan.divideMessage(text);
    int size = dividedMessages.size();
    return text.length() + "/" + size;
}

From source file:Main.java

public static <T> void flipStack(Stack<T> stack) {
    ArrayList<T> tmp = new ArrayList<>(stack);
    stack.clear();//from   w  w w  .ja  v  a  2s.  c  o  m
    for (int i = tmp.size() - 1; i >= 0; i--)
        stack.push(tmp.get(i));
}

From source file:Main.java

private static Bitmap buildBitmap(ArrayList<Bitmap> bitmaps) {
    if (bitmaps == null || bitmaps.size() == 0) {
        return null;
    }/*from  w  w w.j  a v a 2s  .  co m*/
    int width = 0;
    int height = 0;
    for (int i = 0; i < bitmaps.size(); i++) {
        width = width + bitmaps.get(i).getWidth();
        height = Math.max(height, bitmaps.get(i).getHeight());
    }
    Bitmap resultBitmap = Bitmap.createBitmap(width, height, Config.ARGB_4444);
    int drawWidth = 0;
    Canvas canvas = new Canvas(resultBitmap);
    for (int j = 0; j < bitmaps.size(); j++) {
        drawWidth = j * bitmaps.get(j).getWidth();
        canvas.drawBitmap(bitmaps.get(j), drawWidth, 0, null);
    }
    return resultBitmap;
}

From source file:Main.java

/**
 * Converts List of Characters to String.
 * @param characters input list./*from   w  w  w  .jav a 2  s.  c  om*/
 * @return String value.
 */
public static String getText(ArrayList<Character> characters) {
    char[] chars = new char[characters.size()];

    for (int i = 0; i < chars.length; i++) {
        chars[i] = characters.get(i);
    }
    return new String(chars);
}

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 += ",";
        }//  w  w w .  j  a  va  2 s. co  m
        retStr += emails.get(i);
    }
    return retStr;
}