Here you can find the source of join(final Collection
Parameter | Description |
---|---|
input | a parameter |
link | a parameter |
public static <O extends Object> String join(final Collection<O> input, final String link)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.Collection; public class Main { /**/*from w w w . ja v a2 s . c o m*/ * Join parts with link, starting from startIndex. * @param input * @param startIndex * @param link * @return */ public static <O extends Object> String join(O[] input, int startIndex, String link) { return join(Arrays.copyOfRange(input, startIndex, input.length), link); } /** * Join parts with link. * * @param input * @param link * @return */ public static <O extends Object> String join(O[] input, String link) { return join(Arrays.asList(input), link); } /** * Join parts with link. * * @param input * @param link * @return */ public static <O extends Object> String join(final Collection<O> input, final String link) { final StringBuilder builder = new StringBuilder(Math.max(300, input.size() * 10)); boolean first = true; for (final Object obj : input) { if (!first) builder.append(link); builder.append(obj.toString()); first = false; } return builder.toString(); } }