0

With the following line of code:

System.out.println(Arrays.toString(ar));

My output is like this:

[2, 4, 6, 8, 8]

And when I simply print out the array:

System.out.println(ar);

My output is:

[I@78f1f2cc

How do I print out 2 4 6 8 8 without using a for loop?

Sai Wai Maung
  • 1,607
  • 6
  • 18
  • 28
  • 2
    Use `Arrays#toString` or `Arrays#deepToString`. – Luiggi Mendoza Oct 06 '14 at 14:59
  • If you're just interested in an output without commas and brackets you can replace all of them using `.replace`, no? – Compass Oct 06 '14 at 15:01
  • @LuiggiMendoza, I used Arrays.toString, however what I want is to print out the content of the array without comma and brackets. How is this a duplicate to the link that you provided? All the answers in the link that you provided use either Arrays.toString or Arrays.deepToString. – Sai Wai Maung Oct 06 '14 at 15:17
  • Check [this answer](http://stackoverflow.com/a/19201690/1065197) and adapt it to your needs. – Luiggi Mendoza Oct 06 '14 at 15:18

0 Answers0