Here you can find the source of implode(Object strarr[], String delim)
Parameter | Description |
---|---|
strarr | a parameter |
delim | a parameter |
public static final String implode(Object strarr[], String delim)
//package com.java2s; // it under the terms of the GNU General Public License as published by public class Main { /**//w w w . j a v a 2 s. co m * Mimicking the php implode function. Takes any iterable object, and * implodes its components using their .toString() method, putting the * delimiter delim between each of them. * * @param strarr * @param delim * @return */ @SuppressWarnings("unchecked") public static final String implode(Iterable strarr, String delim) { String res = ""; String del = ""; int i = 0; for (Object c : strarr) { i++; if (i > 1) del = delim; res += (del + c.toString()); } return res; } /** * Same as implode(Iterable strarr, String delim), but taking an array * instead of an Iterable object. * * @param strarr * @param delim * @return */ public static final String implode(Object strarr[], String delim) { String res = ""; String del = ""; int i = 0; for (Object c : strarr) { i++; if (i > 1) del = delim; res += (del + c.toString()); } return res; } }