Here you can find the source of printArray(Object[] arr)
Parameter | Description |
---|---|
arr | The array of objects. |
public static String printArray(Object[] arr)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w .j a v a2 s . c om*/ * Prints an array of stuff, with the notation {x1,x2,x3...,xn}, or "" if the array is empty. * Each passed object will be printed according to its arr[i].toString() output. * @param arr The array of objects. * @return The string representation of the passed array as {x1,x2,x3...,xn}, or "" is array empty. */ public static String printArray(Object[] arr) { String toPrint = ""; if (arr.length > 0) { toPrint = "{"; for (int i = 0; i < arr.length; i++) { toPrint += arr[i].toString(); if (i < arr.length - 1) toPrint += ","; } toPrint += "}"; } return toPrint; } }