Here you can find the source of join(final List> things, final String on)
public static String join(final List<?> things, final String on)
//package com.java2s; //License from project: Apache License import java.util.Iterator; import java.util.List; public class Main { public static String join(final List<?> things, final String on) { final StringBuilder sb = new StringBuilder(); for (final Iterator<?> i = things.iterator(); i.hasNext();) { sb.append(i.next());//w w w .j a v a 2s. c o m if (i.hasNext()) { sb.append(on); } } return sb.toString(); } public static String join(final Object[] things, final String on) { final StringBuilder sb = new StringBuilder(); for (int i = 0, len = things.length; i < len; i++) { sb.append(things[i]); if (i < len - 1) { sb.append(on); } } return sb.toString(); } }