wood burning stoves*
The moose likes Beginning Java and the fly likes Output of array only on one line - any ideas why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Output of array only on one line - any ideas why?" Watch "Output of array only on one line - any ideas why?" New topic
Author

Output of array only on one line - any ideas why?

celine scarlett
Ranch Hand

Joined: Nov 06, 2005
Posts: 93
Hi,

This is probably an incredibly simple question, but when I output the results of a sort method on an array list of 10,000 integers, it currently outputs the result as one long list of the 10,000 numbers on one line. They are sorted correctly, but the output of the sort is not suitable for easy presentation.

I currently can't see why this would happen.

Any ideas please!!!

My code is as follows:



Any help or advice appreciated!!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Celine,
You can use "\n" to output a new line character. So using:

in your loop (in the toString() method) will give you what you are trying to do.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
celine scarlett
Ranch Hand

Joined: Nov 06, 2005
Posts: 93
Hi,

Jeanne, you are absolute star. It works perfectly now.

Thank you so much!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Output of array only on one line - any ideas why?