Here you can find the source of join(Iterable
Parameter | Description |
---|---|
source | a parameter |
separator | a parameter |
public static String join(Iterable<String> source, String separator)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { /**/* w w w . j a va2s . c o m*/ * Join an Iterable of String into one string with a separator * @param source * @param separator */ public static String join(Iterable<String> source, String separator) { Iterator<String> iterator = null; if (source == null) { return ""; } iterator = source.iterator(); if (!(iterator.hasNext())) { return ""; } StringBuilder builder = new StringBuilder(iterator.next()); while (iterator.hasNext()) { builder.append(separator).append(iterator.next()); } return builder.toString(); } }