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

/**
 * Concatenate two String arrays./*from w  ww .  j ava 2s. c  o  m*/
 * @param array1 cannot be null.
 * @param array2 cannot be null.
 * @return result.
 */
public static String[] concat(String[] array1, String[] array2) {
    ArrayList<String> result = new ArrayList<>();
    result.addAll(Arrays.asList(array1));
    result.addAll(Arrays.asList(array2));
    String[] array = new String[result.size()];
    result.toArray(array);
    return array;
}

From source file:Main.java

public static String arrayParamToString(ArrayList<String> strings) {

    String arrayToStringParam = "";

    if (strings != null && !strings.isEmpty()) {

        for (int i = 0; i < strings.size(); i++) {

            String param = strings.get(i);

            if (i == 0)
                arrayToStringParam += param;
            else/*from   ww w  .j  av  a 2  s . com*/
                arrayToStringParam += "," + param;

        }
    }

    return arrayToStringParam;
}

From source file:Main.java

/**
 * returns the index of the serached string from the array. If not found returns -1.
 * //ww w  .ja v  a 2 s.c o  m
 * @param strValues
 * @param strSearchedValue
 * @return
 */
public static int getIndex(ArrayList<String> alValues, String strSearchedValue) {

    // cycles on the vcalues of the array
    for (int j = 0; j < alValues.size(); j++) {

        // gets the j-th element
        String strVal = alValues.get(j);

        // if is the searched one, returns its index
        if (strVal.equals(strSearchedValue))
            return j;
    }

    // if arrives here, the searched value hasn't been found
    return -1;
}

From source file:Main.java

public static String[] getValueByGap(int max, int min, int gap) {

    ArrayList<String> list = new ArrayList<String>();
    for (int i = min; i <= max; i += gap) {
        list.add(String.valueOf(i));
    }/* w  w w  .j  a  v  a2 s .  co  m*/
    String[] s = new String[list.size()];
    return list.toArray(s);
}

From source file:hivemall.fm.FieldAwareFactorizationMachineUDTFTest.java

private static String[] toStringArray(ArrayList<StringFeature> x) {
    final int size = x.size();
    final String[] ret = new String[size];
    for (int i = 0; i < size; i++) {
        ret[i] = x.get(i).toString();//  w w w  .  j a  va  2 s .c o  m
    }
    return ret;
}

From source file:src.Piechart.java

private static PieDataset createDataset(ArrayList<String> ColumnNames, ArrayList<Double> Values) {
    DefaultPieDataset dataset = new DefaultPieDataset();

    for (int i = 0; i < ColumnNames.size(); i++) {
        dataset.setValue(ColumnNames.get(i), Values.get(i));
    }/* www  .j  a va 2s  . c o  m*/
    return dataset;
}

From source file:com.lucidtechnics.blackboard.util.Utility.java

public static ArrayList getAllTypes(ArrayList _searchDomainList, ArrayList _allTypesList) {
    for (int i = 0; i < _searchDomainList.size(); i++) {
        Class searchClass = (Class) _searchDomainList.get(i);
        _searchDomainList.remove(searchClass);

        Class superClass = searchClass.getSuperclass();

        if (superClass != null && (_allTypesList.contains(superClass) == false)) {
            _searchDomainList.add(superClass);
            _allTypesList.add(superClass);
        }//w  w  w. j a v a 2 s  . c  o m

        Class[] interfaceArray = searchClass.getInterfaces();

        if (interfaceArray != null) {
            for (int j = 0; j < interfaceArray.length; j++) {
                if (interfaceArray[j] != null && (_allTypesList.contains(interfaceArray[j]) == false)) {
                    _searchDomainList.add(interfaceArray[j]);
                    _allTypesList.add(interfaceArray[j]);
                }
            }
        }
    }

    if (_searchDomainList.isEmpty() == false) {
        _allTypesList = getAllTypes(_searchDomainList, _allTypesList);
    }

    return _allTypesList;
}

From source file:com.piusvelte.taplock.client.core.TapLock.java

protected static String[] getDeviceNames(ArrayList<JSONObject> devices) {
    String[] deviceNames = new String[devices.size()];
    int d = 0;//from   w w w  .j  a va  2 s . c  o m
    for (JSONObject device : devices) {
        try {
            deviceNames[d++] = device.getString(KEY_NAME);
        } catch (JSONException e) {
            Log.e(TAG, e.toString());
        }
    }
    return deviceNames;
}

From source file:Main.java

public static String toString(ArrayList<String> arrayList, String separator, int indexStart, int indexTo) {
    StringBuilder sb = new StringBuilder();

    for (int i = indexStart; i < arrayList.size(); i++) {
        if (i > indexTo) {
            continue;
        }//  ww  w  . ja  v  a  2s.c o m

        if (i > indexStart) {
            sb.append(separator);
        }

        sb.append(arrayList.get(i));
    }

    return sb.toString();
}

From source file:biblioteca.reportes.ChartCreator.java

public static DefaultPieDataset asignarPieDataset(ArrayList<String> Valores) {
    DefaultPieDataset dataSet = new DefaultPieDataset();
    int size = Valores.size();
    size = (size <= 32) ? size : 32;//from  w  ww.  j a  va  2  s  . c om
    for (int i = 2; i < size; i += 2) {
        dataSet.setValue(Valores.get(i), Double.parseDouble(Valores.get(i + 1)));
    }
    return dataSet;
}