Here you can find the source of join(Collection> s, String delimiter)
Parameter | Description |
---|---|
s | a parameter |
delimiter | a parameter |
public static String join(Collection<?> s, String delimiter)
//package com.java2s; import java.util.*; public class Main { /**// w w w .j a v a 2 s.c om * Given a collection of stuff, joins their string representation into one * string using delimiter * * @param s * @param delimiter * @return */ public static String join(Collection<?> s, String delimiter) { StringBuilder builder = new StringBuilder(); Iterator<?> iter = s.iterator(); while (iter.hasNext()) { builder.append(iter.next()); if (!iter.hasNext()) { break; } builder.append(delimiter); } return builder.toString(); } }