Here you can find the source of implode(String delim, Object[] array)
Parameter | Description |
---|---|
delim | Delimiter between each array element |
array | Array of elements |
public static String implode(String delim, Object[] array)
//package com.java2s; /* /*from w w w. j a v a2 s . com*/ * Copyright (C) 2014 Institute for Bioinformatics and Systems Biology, University Giessen, Germany * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Joins array elements in a String. * @param delim Delimiter between each array element * @param array Array of elements * @return String */ public static String implode(String delim, Object[] array) { String asImplodedString; if (array.length == 0) { asImplodedString = ""; } else { StringBuilder sb = new StringBuilder(); sb.append(array[0]); for (int i = 1; i < array.length; i++) { sb.append(delim); sb.append(array[i]); } asImplodedString = sb.toString(); } return asImplodedString; } }