You can use the static methods of the utility found in the java.util.Arrays class:
public static String toString(Object[] a) ie: String dump = Arrays.toString(array);
Returns a string representation of the contents of the specified array.
If the array contains other arrays as elements, they are converted to strings by the Object.toString () method, inherited from Object, which describes their identifiers, and not their contents.
The value returned by this method is equal to the value that Arrays.asList (a) .toString () will return if a is not null, in which case "null" is returned.
public static String deepToString(Object[] a) ie: String dump = Arrays.deepToString(array);
Returns a string representation of the "deep content" of the specified array. If the array contains other arrays as elements, the string view contains their contents, etc. This method is designed to convert multidimensional arrays to strings.
A string representation consists of a list of array elements enclosed in square brackets ("[]"). Adjacent elements are separated by "," (a comma followed by a space). Elements are converted to strings as if by String.valueOf (Object), if they themselves are not arrays.
In the case of colletions, you can use the toArray () method:
List<YourObject> list = ..... YourObject[] array = list.toArray(new YourObject[0]); String dump = Arrays.deepToString(array);
ᴳᵁᴵᴰᴼ
source share