开发者

Java: Printing array in one command

开发者 https://www.devze.com 2023-04-01 00:36 出处:网络
How can I print an array, array1, in one command like array.toString or something similar that actuallyprints array1 as an array like 1 3 4 or something simila开发者_运维知识库r and not as a string li

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

精彩评论

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

关注公众号