Convert Multidimensional Array toString In Java

You can convert a Multidimensional Array toString In Java using the helper utility class for Array called as Arrays.

import java.util.Arrays;

public class MultidimensionalArrayToString {

    public static void main(String[] args) {
        Integer[][] multidimensionalArray = {{1,2,3,4},{5,6,7,8},{9,10}};

[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10]]

We made use of the deepToString() from the java.utils.Arrays class.

Arrays.deepToString() method returns "null" if the specified array is null.
Returns: a string representation of provided input array
Since: Java 1.5
Java Multidimensional Array toString

Have Questions? Post them here!