Skip to content
Advertisement

How do I convert [[Ljava.lang.String;@7defb4fb] to a String

I am trying to print the String, below is the code:

JavaScript

but I get following output in the console:

JavaScript

I have tried the following snippets:

JavaScript

But all of these are giving similar strange output:

JavaScript

How do I get the string value out of it?

**

Edit:

** My problem was to print and array of an array in Java. First thing was to recognize that its nested arrays and hence when I try to iterate over the array and print its elements it was printing the address of the address instead of the element.

[Ljava.lang.String;@7defb4fb]

My problem was to recognize this as an array and iterate over this array again in order to print the elements. Hence here was the solution

JavaScript

Advertisement

Answer

You can try instanceof and then cast it to String[].

Sample code:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement