Here you can find the source of join(Iterable
Parameter | Description |
---|---|
items | a parameter |
delimiter | a parameter |
public static <T> String join(Iterable<T> items, String delimiter)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { /**// www .java 2 s .c om * @param items * @param delimiter * @return delimiter separated string of items */ public static <T> String join(Iterable<T> items, String delimiter) { Iterator<T> i = items.iterator(); if (!i.hasNext()) return ""; StringBuilder sb = new StringBuilder(); sb.append(i.next()); while (i.hasNext()) { sb.append(delimiter); sb.append(i.next()); } return sb.toString(); } }