开发者

Java: Printing array in one command

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜