Java Object Array to String objectArrayToString(Object[] arr)

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

Description

Utility to convert an Object[] to a String.

License

Open Source License

Parameter

Parameter Description
arr The Object[]

Return

String version

Declaration

public static String objectArrayToString(Object[] arr) 

Method Source Code

//package com.java2s;
/**********************************************************************
Copyright (c) 2003 Andy Jefferson and others. All rights reserved. 
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//  w w w . j a  v  a 2 s . c  o  m
    
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.
     
    
Contributors:
2003 Erik Bengtson - moved replaceAll from Column class to here
2004 Andy Jefferson - moved intArrayToString, booleanArrayToString from SM
2007 Xuan Baldauf - toJVMIDString hex fix
...
**********************************************************************/

public class Main {
    /**
     * Utility to convert an Object[] to a String.
     * @param arr The Object[]
     * @return String version
     **/
    public static String objectArrayToString(Object[] arr) {
        if (arr == null) {
            return "null";
        }

        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < arr.length; ++i) {
            if (i > 0) {
                sb.append(", ");
            }
            sb.append(arr[i]);
        }
        sb.append(']');

        return sb.toString();
    }
}

Related

  1. convertObjectToString(Object obj)
  2. convertObjectToString(Object obj)
  3. convertObjectToString(Object object)
  4. convertObjectToString(Object value)
  5. objectArrayToString(Object object)
  6. objectArrayToString(Object[] arr, String name)
  7. objectArrayToString(Object[] objArray, String separator)
  8. objectArrayToString(Object[] objectArray)
  9. objectArrayToString(Object[] objects)