-1

When I use Arrays.toString() on the string aryLines*, it returns: [Ljava.lang.String;@2f67d81 What am I doing wrong, Am I print ing the exact memory location and not the array itself? If so, how do I print the contents of the array?

*The array aryLines is equal to <example><XML><tags>

Steampunkery
  • 3,839
  • 2
  • 19
  • 28

1 Answers1

2

you are printing it wrong, the toString() of any object just prints a textual representation of the given object you called the function. so it means that if you call Array.toString it will print [Ljava.lang.String;@2f67d81 this is the textual memory representation of the object. a very good way to solve this is to use a List, its way more friendly than arrays, and you can print them really easy. if you need arrays just use this

String[] aryLines;
System.out.println(Arrays.asList(aryLines));

this should give you a proper output of the elements contained in your array

cmonkey
  • 4,256
  • 1
  • 26
  • 46
lacripta
  • 112
  • 3
  • 15