13 January 2012

How to create meaninful toString() from Array in java ??

Reminder for myself

Normal array when you use method toString() produce nice but useless "memory adress gibberish".However if you want  meaningful representation of array as string then use this method (from Arrays class):

Arrays.toString(myAwesomeArray)  - where myAwesomeArray is  .... your array ;P

Simple and useful,but i discover that that it use more memory,so it can happen that will see this error for reallly really huge array:
Java heap space
java.lang.OutOfMemoryError: Java heap space