Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Arrays; import java.util.List; public class Main { public static <T> String join(List<T> array, String separator) { if (array == null || separator == null) { return ""; } StringBuilder result = new StringBuilder(); for (T item : array) { if (result.length() > 0) { result.append(separator).append(String.valueOf(item)); } else { result.append(String.valueOf(item)); } } return result.toString(); } public static <T> T[] append(T[] array, T element) { final int N = array.length; array = Arrays.copyOf(array, N + 1); array[N] = element; return array; } }