File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes printing with reserved spaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "printing with reserved spaces" Watch "printing with reserved spaces" New topic

printing with reserved spaces

Margaret Tan

Joined: Sep 14, 2001
Posts: 20
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!
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
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).]

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: printing with reserved spaces
It's not a secret anymore!