Java tutorial
//package com.java2s; public class Main { public static <T> String join(Iterable<T> collection, String conjunction) { StringBuilder sb = new StringBuilder(); boolean isFirst = true; for (T item : collection) { if (isFirst) { isFirst = false; } else { sb.append(conjunction); } sb.append(item); } return sb.toString(); } public static <T> String join(T[] array, String conjunction) { StringBuilder sb = new StringBuilder(); boolean isFirst = true; for (T item : array) { if (isFirst) { isFirst = false; } else { sb.append(conjunction); } sb.append(item); } return sb.toString(); } }