Here you can find the source of join(Object[] values, String join)
public static String join(Object[] values, String join)
//package com.java2s; /*//from w ww .jav a2 s. com * Copyright 2009 Bart Guijt and others. * * 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. */ import java.util.List; public class Main { /** * Joins the values of the array together separated by the join argument. */ public static String join(Object[] values, String join) { if (values == null) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < values.length; i++) { if (i > 0) { sb.append(join); } sb.append(values[i]); } return sb.toString(); } public static String join(List<?> values, String join) { if (values == null) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < values.size(); i++) { if (i > 0) { sb.append(join); } sb.append(values.get(i)); } return sb.toString(); } }