Java tutorial
//package com.java2s; /* * Copyright 2007 Yusuke Yamamoto * * 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 { public static String join(final int[] follows) { final StringBuffer buf = new StringBuffer(11 * follows.length); for (final int follow : follows) { if (0 != buf.length()) { buf.append(","); } buf.append(follow); } return buf.toString(); } public static String join(final long[] array, final char token) { final StringBuilder builder = new StringBuilder(); for (final long item : array) { if (0 != builder.length()) { builder.append(token); } builder.append(item); } return builder.toString(); } public static String join(final String[] array, final char token) { final StringBuilder builder = new StringBuilder(); for (final String str : array) { if (0 != builder.length()) { builder.append(token); } builder.append(str); } return builder.toString(); } }