Home  >  Core Java

Example of Arrays.deepToString in java

By Arvind Rai, May 18, 2013
Arrays.deepToString in java converts multi dimensional array to string. Arrays.deepToString checks if an array has the element as an array then it converts that array in String. String representtaions are in the format [[],[]].
DeepToStringDemo.java
package com.util;
import java.util.Arrays;
public class DeepToStringDemo {
    public static void main(String[] args) {
      String[][] multiDim = {
                              {"Hello "," Ram"},
                              {"how ","are you."}
                          };
     String s = Arrays.deepToString(multiDim);
     System.out.println(s);
     int[][] multiDimInt = {
                               {1,2},
                               {3,4}
                           };
     s = Arrays.deepToString(multiDimInt);
    System.out.println(s);
  }
}
Output
[[Hello ,  Ram], [how , are you.]]
[[1, 2], [3, 4]]  
POSTED BY
ARVIND RAI
ARVIND RAI
FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us