Java arrays printing out weird numbers and text [duplicate]

Every object has a toString() method, and the default method is to display the object’s class name representation, then @ followed by its hashcode. So what you’re seeing is the default toString() representation of an int array. To print the data in the array, you can use:

System.out.println(java.util.Arrays.toString(arr));

Or, you can loop through the array with a for loop as others have posted in this thread.

Leave a Comment