Here you can find the source of printArrayOfUnknownObjectsOnePerLine(Object[] array)
public static void printArrayOfUnknownObjectsOnePerLine(Object[] array)
//package com.java2s; /**/*from w w w . ja va2s . c om*/ * <p> * This software is distributed under the <a href="http://hci.stanford.edu/research/copyright.txt"> * BSD License</a>. * </p> * * @author <a href="http://graphics.stanford.edu/~ronyeh">Ron B Yeh</a> (ronyeh(AT)cs.stanford.edu) */ public class Main { /** * @created Feb 7, 2006 * @author Ron Yeh */ public static void printArrayOfUnknownObjectsOnePerLine(Object[] array) { final StringBuffer sb = new StringBuffer(); sb.append("Object Array: [\n"); for (Object o : array) { final String fullyQualifiedName = o.getClass().toString(); final String shortClassName = fullyQualifiedName.substring(fullyQualifiedName.lastIndexOf(".") + 1, fullyQualifiedName.length()); sb.append("\t(" + shortClassName + ": " + o.toString() + ")\n"); } System.out.println(sb.substring(0, sb.length() - 1) + "]"); } /** * @param array * turns an array of ints into a String */ public static String toString(int[] array) { StringBuilder sb = new StringBuilder(); sb.append("["); for (int i : array) { sb.append(i + ", "); } if (sb.length() > 1) { sb.delete(sb.length() - 2, sb.length()); } sb.append("]"); return sb.toString(); } /** * @param array * @return */ public static String toString(Object[] array) { StringBuilder sb = new StringBuilder(); sb.append("["); for (Object o : array) { sb.append(o + ", "); } if (sb.length() > 1) { sb.delete(sb.length() - 2, sb.length()); } sb.append("]"); return sb.toString(); } }