Example code:
/** Returns input as a comma-separated list. If input if null
* or empty, then this returns an empty string. */
public static String convertToString(Object... objects) {
if (objects == null || objects.length == 0) { return ""; }
StringBuilder sb = new StringBuilder();
for (Object object : objects) {
sb.append(object.toString()).append(", ");
}
return sb.substring(0, sb.length() - 2).
No comments:
Post a Comment