Here you can find the source of join(List objects)
Parameter | Description |
---|---|
objects | A list of objects to concatenate. |
@SuppressWarnings("rawtypes") public static String join(List objects)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**//from w w w . ja va 2 s. com * Concatenate a list of objects into a single string (using their * "toString" method), joining them with a ",". * * @param objects * A list of objects to concatenate. * @return */ @SuppressWarnings("rawtypes") public static String join(List objects) { return join(",", objects); } /** * Concatenate a list of objects into a single string (using their * "toString" method), joining them with a specified glue string. * * @param glue * A string to use to join the objects. * @param objects * A list of objects to concatenate. * @return */ @SuppressWarnings("rawtypes") public static String join(String glue, List objects) { StringBuilder sb = new StringBuilder(); for (Object o : objects) { if (sb.length() > 0) sb.append(glue); sb.append(o.toString()); } return sb.toString(); } }