Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Iterator; public class Main { public static String repeat(String pattern, int count) { final StringBuilder builder = new StringBuilder(); for (int i = 0; i < count; i++) { builder.append(pattern); } return builder.toString(); } public static String toString(Object object) { if (object == null) { return "null"; } return object.toString(); } public static String toString(Iterable<?> it, String separator) { final StringBuilder builder = new StringBuilder(); final Iterator<?> iterator = it.iterator(); while (iterator.hasNext()) { builder.append(iterator.next().toString()); if (iterator.hasNext()) { builder.append(separator); } } return builder.toString(); } }