Here you can find the source of join(Object[] array, String separator)
Parameter | Description |
---|---|
array | a parameter |
separator | a parameter |
public static String join(Object[] array, String separator)
//package com.java2s; /*/* www .j ava 2 s. c o m*/ * Copyright (c) 2007-2012 The Broad Institute, Inc. * SOFTWARE COPYRIGHT NOTICE * This software and its documentation are the copyright of the Broad Institute, Inc. All rights are reserved. * * This software is supplied without any warranty or guaranteed support whatsoever. The Broad Institute is not responsible for its use, misuse, or functionality. * * This software is licensed under the terms of the GNU Lesser General Public License (LGPL), * Version 2.1 which is available at http://www.opensource.org/licenses/lgpl-2.1.php. */ import java.util.List; public class Main { public static String join(List list, String separator) { return join(list.toArray(), separator); } /** * Join the objects in {@code array} with the given {@code separator} * Useful for making a comma separated list, or URL query string * @param array * @param separator * @return */ public static String join(Object[] array, String separator) { int num = array.length; if (num == 0) return ""; String out = array[0].toString(); for (int ii = 1; ii < num; ii++) { out += (separator + array[ii].toString()); } return out; } }