Here you can find the source of toString(String arrayName, T[] targets)
public static <T> String toString(String arrayName, T[] targets)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**/*from w ww .j av a 2 s . com*/ * Constructs a String representation of an array and its values. */ public static <T> String toString(String arrayName, T[] targets) { final int n = targets.length; StringBuilder sb = new StringBuilder(); // Generate value sb.append(arrayName).append(" { "); for (int i = 0; i < n; i++) { sb.append(targets[i].toString()); if (i + 1 < n) sb.append(","); sb.append(" "); } return sb.append("}").toString(); } /** * Constructs a String representation of an array and its values. */ public static <T> String toString(T[] targets) { return toString(targets.getClass().getSimpleName(), targets); } /** * Constructs a String representation of a {@link List} and its values. */ public static <T> String toString(List<T> values) { return toString(values.toArray()); } /** * Constructs a String representation of a {@link List} and its values. */ public static <T> String toString(String arrayName, List<T> values) { return toString(arrayName, values.toArray()); } }