Here you can find the source of joinRepeat(int size, String s, String delim)
public static String joinRepeat(int size, String s, String delim)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; public class Main { public static String joinRepeat(int size, String s, String delim) { return join(repeatList(size, s), delim); }//w w w.j av a 2 s . c o m public static String join(Collection<?> s, String delimiter) { StringBuilder builder = new StringBuilder(); Iterator iter = s.iterator(); while (iter.hasNext()) { builder.append(iter.next().toString()); if (!iter.hasNext()) { break; } builder.append(delimiter); } return builder.toString(); } public static List<String> repeatList(int n, String s) { List<String> list = new ArrayList<String>(); for (int i = 0; i < n; i++) { list.add(s); } return list; } }