Here you can find the source of join(Iterable
Parameter | Description |
---|---|
s | a parameter |
delimiter | a parameter |
public static String join(Iterable<String> s, String delimiter)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**// w w w . ja v a 2 s . co m * Joins array of strings to string * * @param s * @param delimiter * @return */ public static String join(Iterable<String> s, String delimiter) { if (s == null) return ""; Iterator<String> iter = s.iterator(); StringBuilder builder = new StringBuilder(iter.next()); while (iter.hasNext()) { builder.append(delimiter).append(iter.next()); } return builder.toString(); } }