This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Leading Spaces instead of zeros? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Leading Spaces instead of zeros?" Watch "Leading Spaces instead of zeros?" New topic

Leading Spaces instead of zeros?

John Hunkle

Joined: Feb 20, 2001
Posts: 3
The following program displays
instead of

What do I need to change/add in order to get the desired output?
Thanks much in advance.

The desired output should be aligned on the decimal points (i.e. the zeros in the actual output should be spaces/' ')
Desired output is:

(Edited by Cindy to combine three posts)
[This message has been edited by Cindy Glass (edited February 21, 2001).]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Your method call "fmt.setMinimumIntegerDigits (4)" is the problem. You don't need it.


So much trouble in the world -- Bob Marley
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
You could use the decimalFormat() to make the number of digits after the decimal the same and the right justify them all. I can't find any other method.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: Leading Spaces instead of zeros?
It's not a secret anymore!