This method returns a string representation of the "deep contents" of the specified array. If the array contains other arrays as elements, the string representation contains their contents and so on.
package com.logicbig.example.arrays;
import java.util.Arrays;
public class DeepToStringExample {
public static void main(String... args) {
Object[] arr1 = {3, 5, new Object[]{6, 7, new int[]{9, 11}}};
String s1 = arr1.toString();
System.out.println(s1);
String s2 = Arrays.toString(arr1);
System.out.println(s2);
String s3 = Arrays.deepToString(arr1);
System.out.println(s3);
}
}
Output
[Ljava.lang.Object;@16884b5f
[3, 5, [Ljava.lang.Object;@5a97eed0]
[3, 5, [6, 7, [9, 11]]]
package com.logicbig.example.arrays;
import java.util.Arrays;
public class DeepToStringExample2 {
public static void main(String... args) {
Object[] arr1 = {3, 5, 6, 7};
String s1 = arr1.toString();
System.out.println(s1);
String s2 = Arrays.toString(arr1);
System.out.println(s2);
String s3 = Arrays.deepToString(arr1);
System.out.println(s3);
}
}
Output
[Ljava.lang.Object;@4ea54e29
[3, 5, 6, 7]
[3, 5, 6, 7]