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 similar and not as a string like [I@1242719c. Maybe we can turn it to a ArrayList and then we can print it easily?
-
@lngo:Is this a math ex? I tried 'array.toString' and prints it with a loop. It's whether you recall the static method of Arrays or not, no?Numerator– Numerator2011-09-01 08:14:44 +00:00Commented Sep 1, 2011 at 8:14
-
no it's not a math ex. It's a question of politeness if one expects help to give as detailed information as possible. Please remember that people answering here do that voluntary, it's not that they are paid by stackoverflow and it's there duty.Ingo– Ingo2011-09-01 08:18:42 +00:00Commented Sep 1, 2011 at 8:18
-
Sure, but i did explain what I think or suggested the ArrayList. I don't know what you more expected. Writing in the question: "How can I print an array in one command?" would be rude indeed.Numerator– Numerator2011-09-01 08:29:24 +00:00Commented Sep 1, 2011 at 8:29
Add a comment
|
3 Answers
Arrays.toString(myArray);
According to the javadoc, it calls the toString() method of the objects in your array.