How can I print an array, array1
, in one command like array.toString
or something similar that actually prints array1
as an array like 1 3 4
or something simila开发者_运维知识库r and not as a string like [I@1242719c
. Maybe we can turn it to a ArrayList
and then we can print it easily?
Arrays.toString(array1)
and if it is multidimensional array
Arrays.deepToString(array1)
Arrays.toString(array1)
should do the trick
Arrays.toString(myArray);
According to the javadoc, it calls the toString()
method of the objects in your array.
精彩评论