Java Array Print printArray(Object[] array)

Here you can find the source of printArray(Object[] array)

Description

Print an array to console.

License

Open Source License

Parameter

Parameter Description
array a parameter

Declaration

public static void printArray(Object[] array) 

Method Source Code

//package com.java2s;
/**//w  w w.  ja  v  a 2 s.c  o m
 * Generally useful methods for system-level operations.
 * 
 * @author ronyeh, srk
 * 
 * <p>
 * This software is distributed under the <a
 * href="http://hci.stanford.edu/research/copyright.txt">Berkeley Software
 * Distribution License</a>.
 * </p>
 * 
 * @author <a href="http://graphics.stanford.edu/~ronyeh">Ron Yeh</a> (
 *         ronyeh(AT)cs.stanford.edu )
 * @author <a href="http://hci.stanford.edu/srk">Scott Klemmer</a> (
 *         srk(AT)cs.stanford.edu )
 */

public class Main {
    /**
     * Print an array to console.
     * 
     * @param array
     */
    public static void printArray(Object[] array) {
        String className = array[0].getClass().toString();
        System.out.print(className.substring(className.lastIndexOf(".") + 1, className.length()) + " Array: [");
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]);
            if (i != array.length - 1) {
                System.out.print(", ");
            }
        }
        System.out.println("]");
    }
}

Related

  1. printArray(int[] array)
  2. printArray(int[] array, int start, int end)
  3. printArray(int[] nums)
  4. printArray(Object a[])
  5. printArray(Object[] arr)
  6. printArray(Object[] array)
  7. printArray(Object[] cells)
  8. printArray(Object[] o)
  9. printArray(Object[] strArray, String split)