Here you can find the source of arrayToString(T[] array)
Parameter | Description |
---|---|
array | a parameter |
public static <T> String arrayToString(T[] array)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w.j a v a 2 s. c o m*/ * Provides a string representation for the given array. * @param array * @return */ public static <T> String arrayToString(T[] array) { return arrayToString(array, "", "", " "); } /** * Provides a string representation for the given array, where the prefix and suffix of the string, * as well as the delimited between the array items are given as parameters. * @param array * @param prefix * @param suffix * @param delimiter * @return */ public static <T> String arrayToString(T[] array, String prefix, String suffix, String delimiter) { StringBuilder sb = new StringBuilder(); sb.append(prefix); boolean firstIteration = true; for (T t : array) { if (firstIteration) { firstIteration = false; } else { sb.append(delimiter); } sb.append(t); } sb.append(suffix); return sb.toString(); } }