Java Array to String arrayToString(Object[] arr)

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

Description

array To String

License

Open Source License

Declaration

public static String arrayToString(Object[] arr) 

Method Source Code

//package com.java2s;
/*//w ww  . j a  va2 s . c om
Copyright (c) Microsoft Open Technologies, Inc.
All Rights Reserved
See License.txt in the project root for license information.
*/

public class Main {
    public static String arrayToString(Object[] arr) {
        if (arr == null) {
            return "<<NULL>>";
        } else {
            StringBuilder sb = new StringBuilder();
            sb.append("[");

            for (int i = 0; i < arr.length; i++) {
                Object elem = arr[i];
                sb.append(elem.toString());

                if (i != arr.length - 1) {
                    sb.append(", ");
                }
            }

            sb.append("]");

            return sb.toString();
        }
    }
}

Related

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