I'm trying to convert a String[][]
to a string for display in a GUI. Here's my code:
String[][] tableBornes = SearchPropertiesPlugin.FillBornesTable(); String table = tableBornes.toString();
Here's what it produces:
[[Ljava.lang.String;@19b8858
How can I get something more readable?
We can use the Arrays. toString() method to print string representation of each single-dimensional array in the given two-dimensional array.
Multidimensional PHP Array to String Maybe in case you need to convert a multidimensional array into a string, you may want to use the print_r() function. This is also called “array with keys”. By adding “true” as its second parameter, all the contents of the array will be cast into the string. <?
function convert_multi_array($array) { foreach($array as $value) { if(count($value) > 1) { $array = implode("~", $value); } $array = implode("&", $value); } print_r($array); } $arr = array(array("blue", "red", "green"), array("one", "three", "twenty")); convert_multi_array($arr);
try one line version
Arrays.deepToString(tableBornes);
or multiline version
StringBuilder sb = new StringBuilder(); for(String[] s1 : tableBornes){ sb.append(Arrays.toString(s2)).append('\n'); } String s = sb.toString();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With