List of usage examples for java.util ArrayList size
int size
To view the source code for java.util ArrayList size.
Click Source Link
From source file:Main.java
/** * Implode//from w ww.j av a 2 s . com * @param ids * @return */ public static String convertToCommaDelimitedString(ArrayList<String> ids) { String out = ""; for (int i = 0; i < ids.size(); i++) { if (i != 0) { out += "','"; } out += ids.get(i).toString(); } return "'" + out + "'"; }
From source file:Main.java
public static boolean isScalar(ArrayList<?> shape) { if (shape != null) { for (int i = 0; i < shape.size(); i++) { if (null == shape.get(i) || !("1").equals(shape.get(i).toString())) { return false; }/*w w w .j a v a 2s . c om*/ } } return true; }
From source file:Main.java
public static String convertListToStringForQuery(ArrayList<Integer> list) { String result = "("; for (int i = 0; i < list.size(); i++) { if (i != 0) { result = result + ","; }//from w w w . ja v a 2 s .co m result = result + list.get(i).toString(); } result = result + ")"; return result; }
From source file:Main.java
public static <T> T last(Collection<? extends T> collection) { ArrayList<T> list = new ArrayList<>(collection); return list.isEmpty() ? null : list.get(list.size() - 1); }
From source file:Main.java
private static String getCommonSubStringFromList(ArrayList<String> list) { if (list != null && list.size() > 0) { String[] tokens = ((String) list.get(0)).split("/"); String path = null;// ww w .j a v a 2s . c o m String temp = ""; for (int i = 0; i < tokens.length; ++i) { if (!tokens[i].trim().isEmpty()) { temp = temp + "/" + tokens[i]; if (isValidSubString(list, temp)) { path = temp; } } } return path; } else { return null; } }
From source file:Main.java
private static <T> boolean isInRange(ArrayList<T> list, int position) { return !(position < 0 || position >= list.size()); }
From source file:Main.java
public static <T> boolean isContain(ArrayList<T> a, ArrayList<T> b) { boolean res = false; for (int i = 0; i < b.size(); i++) { if (!a.contains(b.get(i))) { break; }/*from w w w . j a v a 2s. c o m*/ if (i == b.size() - 1) { res = true; } } return res; }
From source file:Main.java
/** * Joins the arraylist into a single string, combining them with commas. * @param list/*from w w w . ja va2s. c o m*/ * @return */ public static String join(ArrayList<String> list) { String item = ""; for (int i = 0; i < list.size(); i++) { if (i > 0) item += ","; item += list.get(i); } return item; }
From source file:Main.java
public static String joinStrings(String connector, ArrayList<String> strings, StringBuilder recycle) { if (strings.size() <= 0) { return ""; }//from w w w. j a v a 2 s. c om if (recycle == null) { recycle = new StringBuilder(); } else { recycle.setLength(0); } recycle.append(strings.get(0)); for (int i = 1; i < strings.size(); i++) { recycle.append(connector); recycle.append(strings.get(i)); } return recycle.toString(); }
From source file:Main.java
public static String getArrayListInString(ArrayList<Integer> array) { String numbers = ""; for (int i = 0; i < array.size(); i++) { numbers = numbers + array.get(i); if (i != array.size() - 1) { numbers = numbers + ", "; }/*from ww w . j a v a2 s . com*/ } return numbers; }