Here you can find the source of printArray(String arrayLabel, Object[] array)
Parameter | Description |
---|---|
arrayLabel | Label for array. |
array | The array to print. <p> N.B. This method assumes the array values have toString() methods. </p> |
public static void printArray(String arrayLabel, Object[] array)
//package com.java2s; /* Please see the license information at the end of this file. */ public class Main { /** Debugging support -- Print contents of an array. *// ww w .j av a 2 s . c o m * @param arrayLabel Label for array. * * @param array The array to print. * * <p> * N.B. This method assumes the array values have toString() methods. * </p> */ public static void printArray(String arrayLabel, Object[] array) { if (array == null) { System.out.println(arrayLabel + " is null."); } else if (array.length == 0) { System.out.println(arrayLabel + " is empty."); } else { System.out.println(arrayLabel); for (int i = 0; i < array.length; i++) { Object value = array[i]; if (value == null) { System.out.println(i + ": null"); } else { System.out.println(i + ": " + value.toString()); } } } } }