• Post Reply Bookmark Topic Watch Topic
  • New Topic

Array printing format  RSS feed

 
Kev Woo
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to print an array with each element spaced a certain distance horizontally like this.

E1 E2 E3 E4

I know how to print an array, but it only prints them out one at a time skipping a line each time.
E1
E2
E3
E4

This is my code for printing my array



how can I print this the way I want?


 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Well, if you use print() instead of println() then that won't print the newline ... then all you have to do is to print the spaces between the elements.

Henry
 
Kev Woo
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haha that would help...

thanks.

also, is there a better way to set the number of spaces between other then adding a + " "); at the end?
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the printf() methods. If the link doesn't supply enough information, be sure to ask again.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peachy Manasis,
Your post was moved to a new topic.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I earlier wrote:Peachy Manasis,
Your post was moved to a new topic.
You have asked a new question on a current thread. That may deprive Kev Woo of an answer to his original question. Please avoid such thread hi-jacking.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!