Thursday, 31 August 2017

Why do I get garbage values when print arrays in Java?

Isn't garbage. Is the default implementation of toString for this class.


The easiest way to get the elements printed on a readable format is:


String printed = Arrays.toString(x);

Documentation for Arrays.toString(int[])


The same approach can be used to print out array of primitives and Objects.

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...