Example usage for java.util List get

List of usage examples for java.util List get

Introduction

In this page you can find the example usage for java.util List get.

Prototype

E get(int index);

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:Main.java

public static final byte[] toByteArray(final List<Byte> pItems) {
    final byte[] out = new byte[pItems.size()];
    for (int i = out.length - 1; i >= 0; i--) {
        out[i] = pItems.get(i);
    }//from  w w w .  ja  v  a2 s.  c o  m
    return out;
}

From source file:Main.java

public static long[] LongListtolongArray(List<Long> LongList) {
    int s = LongList.size();
    long[] ret = new long[s];
    for (int i = 0; i < s; i++) {
        ret[i] = LongList.get(i);
    }/*from w ww .  ja va 2s.c  om*/
    return ret;
}

From source file:Main.java

public static String getAddressFromLoc(Context pContext, double latitude, double longitude) throws IOException {

    Geocoder geocoder = new Geocoder(pContext, Locale.getDefault());
    List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);

    String address = "";
    if (addresses.get(0) != null)
        address = addresses.get(0).getAddressLine(0);

    String city = addresses.get(0).getLocality();
    String zip = addresses.get(0).getPostalCode();
    String country = addresses.get(0).getCountryName();

    address = (address == null) ? "" : address;
    city = (city == null) ? "" : city;
    zip = (zip == null) ? "" : zip;
    country = (country == null) ? "" : country;

    return address + " " + city + " " + zip + " " + country;
}

From source file:Main.java

public static <A> List<A> take(List<A> list, int n) {
    List<A> result = new ArrayList<A>();
    for (int j = 0; j < Math.min(n, list.size()); ++j)
        result.add(list.get(j));
    return result;
}

From source file:Main.java

/************************begin airthmetic ****************************/
public static void printListThroughRandomAccess(List list, String logTag) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < list.size(); i++) {
        sb.append(list.get(i) + " ");
    }/*from   ww  w  . ja v a2 s  . c  om*/

    System.out.println(logTag + " " + "printListThroughRandomAccess::" + sb.toString());
}

From source file:Main.java

/**
 * Function to check if the mandatory fields are present or not.
 * @param playerMandatoryFields list of string .
 * @return true is all are present else will return false
 *///from   w  w w.jav a  2s  .co m
public static boolean isMandatoryFieldsPresent(List<String> listOfMandatoryFields) {
    for (int i = 0; i < listOfMandatoryFields.size(); i++) {
        if (!isValidString(listOfMandatoryFields.get(i))) {
            return false;
        }
    }
    return true;
}

From source file:Main.java

public static final long[] toLongArray(final List<Long> pItems) {
    final long[] out = new long[pItems.size()];
    for (int i = out.length - 1; i >= 0; i--) {
        out[i] = pItems.get(i);
    }//  w ww. j  a v a  2s .  co m
    return out;
}