Java Array to String arrayToString(Object[] arr)

Here you can find the source of arrayToString(Object[] arr)

Description

Converts the specified array into a string by appending all its elements separated by a semicolon.

License

Open Source License

Declaration


public static String arrayToString(Object[] arr) 

Method Source Code

//package com.java2s;
/**/* w  w  w. j a  v  a  2  s .  c om*/
 * The utillib library.
 * More information is available at http://www.jinchess.com/.
 * Copyright (C) 2002, 2003 Alexander Maryanovsky.
 * All rights reserved.
 *
 * The utillib library is free software; you can redistribute
 * it and/or modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * The utillib library 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 Lesser
 * General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with utillib library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
 */

public class Main {
    /**
     * Converts the specified array into a string by appending all its elements
     * separated by a semicolon.
     */

    public static String arrayToString(Object[] arr) {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < arr.length; i++) {
            buf.append(arr[i]);
            buf.append("; ");
        }
        if (arr.length > 0)
            buf.setLength(buf.length() - 2); // get rid of the extra "; "

        return buf.toString();
    }
}

Related

  1. arrayToString(Object[] anArray, String aPrefix, String aSeparator, String aSuffix, String anEscapeChars, char anEscapeSymbol)
  2. arrayToString(Object[] args, String separator)
  3. arrayToString(Object[] arr)
  4. arrayToString(Object[] arr)
  5. arrayToString(Object[] arr)
  6. arrayToString(Object[] arr, String split)
  7. arrayToString(Object[] array)
  8. arrayToString(Object[] array)
  9. arrayToString(Object[] array)