Here you can find the source of join(Iterable
Parameter | Description |
---|---|
array | a parameter |
joiner | The delimiter to add between each element |
public static <T> String join(Iterable<T> array, String joiner)
//package com.java2s; //License from project: Apache License import java.util.Iterator; public class Main { /**//from w w w. ja va 2s .c om * Missing counterpart for String.split() * * @param array * @param joiner The delimiter to add between each element * @return The joined string */ public static <T> String join(Iterable<T> array, String joiner) { StringBuilder b = new StringBuilder(); Iterator<T> i = array.iterator(); boolean first = true; while (i.hasNext()) { if (first) first = false; else b.append(joiner); b.append(i.next()); } return b.toString(); } }