Here you can find the source of implode(String[] stringsArr, String glue)
Parameter | Description |
---|---|
stringsArr | Array of strings |
glue | Glue in between concatenated strings |
public static String implode(String[] stringsArr, String glue)
//package com.java2s; /*/*from www . j av a 2 s .c o m*/ * Copyright 2011-2015 Kay Stenschke * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Concatenate strings of given array glued by given delimiter * * @param stringsArr Array of strings * @param glue Glue in between concatenated strings * @return String All items of stringsArr concatenated with glue */ public static String implode(String[] stringsArr, String glue) { String out = ""; for (int i = 0; i < stringsArr.length; i++) { out += (i != 0 ? glue : "") + stringsArr[i]; } return out; } }