Here you can find the source of concatenate(Collection> list)
public static String concatenate(Collection<?> list)
//package com.java2s; /*/*from w ww.jav a 2 s . co m*/ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ import java.util.Collection; public class Main { public static final String EMPTY = ""; public static final String DEFAULT_DELIMITER = ","; public static String concatenate(Collection<?> list) { return concatenate(list, DEFAULT_DELIMITER); } public static String concatenate(Collection<?> list, String delimiter) { if (list == null || list.isEmpty()) { return EMPTY; } if (delimiter == null) { delimiter = EMPTY; } StringBuilder sb = new StringBuilder(); for (Object object : list) { sb.append(object.toString()); sb.append(delimiter); } sb.setLength(sb.length() - delimiter.length()); return sb.toString(); } }