• Post Reply Bookmark Topic Watch Topic
  • New Topic

printing lines?  RSS feed

 
yara hussien
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

How to display10 numbers per line, separated by exactly one space?
 
Ganish Patil
Ranch Hand
Posts: 529
19
Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!    would you please explain more what precisely you want to display and what have you done for that? Better if you post your code whatsoever you tried although code has bugs.
 
yara hussien
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh thank you very much i got the answer after trying  but here is the code any way , i just wanted to print ten lines and each one has ten results seberated by space

 
salvin francis
Bartender
Posts: 1664
37
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yara Hussien, welcome to code ranch,

In the future, use code tags to add any java code in your comment. I have added them for you in the previous comment.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would have thought a loop would be a better way to print your numbers. I don't like the return statement, which may break off your method before it has finished; you cannot be certain you always want ten lines.
Find out about printf and the %d tag, which will allow you to format the number of spaces for numbers. Read about it in the Java™ Tutorials.
 
yara hussien
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks i will
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!