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

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap