Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

printing with reserved spaces

 
Margaret Tan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I'm writing a program that prints the first 10 times table but the format it is printing in the dos prompt is really ugly, I want to make it aligned, how do I do that? I know in C, I can't remember it exactly but I was pretty sure that it uses like %3.2f to reserve 3 spaces for float, not sure what it was for integers. My question is what is the syntax to reserve spaces in Java using the System.out.println(). Thanks a bunch!
Margaret
 
Marilyn de Queiroz
Sheriff
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no equivalent in java. Here is a link to an alternative. Or you can use the NumberFormat or DecimalFormat class.
[This message has been edited by Marilyn deQueiroz (edited October 07, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic