This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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
internet detective
Marshal

Joined: May 26, 2003
Posts: 26195
    
  66

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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Output of array only on one line - any ideas why?
 
Similar Threads
selection sort: did i miss something?!
Boolean method linked to an array? Please help!!
Sorting an array list into numerical order - help please!!
Boolean method for a class with an array...Please help!!
Searching an array - output problems - Please help!!