File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Java 8 in Action this week in the Java 8 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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

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?
 
Similar Threads
Boolean method linked to an array? Please help!!
Searching an array - output problems - Please help!!
Boolean method for a class with an array...Please help!!
Sorting an array list into numerical order - help please!!
selection sort: did i miss something?!