Back to project page TodoList.
The source code is released under:
Apache License
If you think the Android project TodoList listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package lyc.simplesqlite.util; /*ww w. java 2 s . c om*/ /** * Created by ivan on 14-9-28. */ public class StringUtils { private StringUtils() { } public static <T> String join(T[] obj, Callback<T> callback) { return join(obj, callback, ", "); } public static <T> String join(T[] obj, Callback<T> callback, String chr) { if (obj.length == 0) { return ""; } StringBuilder sb = new StringBuilder(); int len = obj.length - 1; for (int i = 0; ; i++) { sb.append(callback.process(obj[i])); if (i == len) { break; } sb.append(chr); } return sb.toString(); } public static String join(Object[] array, String chr) { if (array.length == 0) { return ""; } StringBuilder sb = new StringBuilder(); int len = array.length - 1; for (int i = 0; ; i++) { sb.append(array[i]); if (i == len) { break; } sb.append(chr); } return sb.toString(); } public static interface Callback<T> { String process(T t); } }