Printing out an array

When printing out an array if you simply do a toString on the array you will get a “fairly useless result such as [C@16f0472”. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array.” I used to use Arrays.asList followed by toString but Arrays.toString is definitely more efficient and is available as of JDK 1.5.0.

This method is useful when you want to report on the values of an JDK 1.5 enum since the values method returns an array.

The quote is from a FindBugs report.

Leave a Reply

Your email address will not be published. Required fields are marked *