Here you can find the source of join(final List
Parameter | Description |
---|---|
data | a parameter |
separator | a parameter |
public static String join(final List<String> data, String separator)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**//from w w w . j av a 2 s . c om * Joins elements in a list with separator. * * @param data * @param separator * @return A joined list, joined by the separator. */ public static String join(final List<String> data, String separator) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < data.size(); i++) { sb.append(data.get(i)); // append with separator unless last element if (i != data.size() - 1) { sb.append(separator); } } return sb.toString(); } }