List of usage examples for java.util List get
E get(int index);
From source file:Main.java
public static boolean isStackResumed(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1); ActivityManager.RunningTaskInfo runningTaskInfo = runningTaskInfos.get(0); return runningTaskInfo.numActivities > 1; }
From source file:Main.java
public static <T> T last(List<T> list) { if (list == null || list.isEmpty()) { return null; }//from ww w . ja v a2 s . c om return list.get(list.size() - 1); }
From source file:Main.java
public static long[] toLongArray(List<Long> arrList) { long[] r = new long[arrList.size()]; for (int i = 0; i < arrList.size(); i++) { r[i] = ((Long) arrList.get(i)).longValue(); }/*from w w w. ja v a2s . com*/ return r; }
From source file:Main.java
public static double[] toDoubleArray(List<Double> list) { double[] result = new double[list.size()]; for (int i = 0; i < list.size(); ++i) { result[i] = list.get(i); }/*from www.ja va 2s .co m*/ return result; }
From source file:Main.java
public static <T> void removeDuplicate(List<T> list) { for (int i = 0; i < list.size(); i++) { for (int j = i + 1; j < list.size(); j++) { if (list.get(i).equals(list.get(j))) { list.remove(j);//from w w w . j a va 2 s . c o m } } } }
From source file:Main.java
public static double[] listToDoubleArray(List<Double> list) { double[] result = new double[list.size()]; for (int i = 0; i < list.size(); i++) { result[i] = list.get(i); }/*w ww .ja v a2s. c o m*/ return result; }
From source file:Main.java
/** * Get child element by classname/*from www . ja va2s.c o m*/ * * @param ele parent element * @param name of elements to find */ public static Element getElementByClass(Element ele, String name) { List<Element> list = getElementsByClass(ele, name); if (list.size() > 0) return list.get(0); return null; }
From source file:Main.java
/** * Returns the first element of a list or null if the list * is null or empty.// w w w .j a va2 s. c o m * * @param l the list in which to find the first element * @return Object the first element of the list */ public static Object getFirstElement(List l) { // Return null if list is null or empty if (l == null || l.isEmpty()) return null; return l.get(0); }
From source file:Main.java
public static String[] toArray(List<String> list) { String[] result = new String[list.size()]; for (int i = 0; i < list.size(); ++i) { result[i] = list.get(i); }//w ww. j av a2 s .c o m return result; }
From source file:Main.java
public static <T> List<Object> listGeneralToObject(List<T> list) { List<Object> retList = new ArrayList<Object>(); for (int i = 0; i < list.size(); i++) { retList.add(list.get(i)); }// ww w. j a va 2 s . c o m return retList; }