help - right allignment of text

E

EB

Im working with Java.
Im writing this program right now.....and one of the thing i have to do is
present a matrix onto the screen....my problem is that i dont know how to
make to make the far right colum of the matrix to be right aligned.
Any help will be much appreciated

heres what i have right now
0.000 0.000 0.000 2.000
0.000 0.000 0.000 12.000
0.000 0.000 0.000 0.000
0.000 0.000 0.000 138.000

HERES WHAT I WANT
0.000 0.000 0.000 2.000
0.000 0.000 0.000 12.000
0.000 0.000 0.000 0.000
0.000 0.000 0.000 138.000

Please help
 
C

Carl Howells

Huan said:
System.out.println("%6.3f%6.3f%6.3f%6.3f", v1, v2, v3, v4);

You *might* want to point out this won't work unless you have jdk 1.5,
which is currently in beta. That would be helpful.
 
T

Thomas Weidenfeller

EB said:
Im working with Java.
Im writing this program right now.....and one of the thing i have to do is
present a matrix onto the screen....my problem is that i dont know how to
make to make the far right colum of the matrix to be right aligned.
Any help will be much appreciated

See the java.text package. And consider posting your beginner's
questions to comp.lang.java.help

/Thomas
 
D

Dale King

Thomas Weidenfeller said:
See the java.text package. And consider posting your beginner's
questions to comp.lang.java.help


Actually nothing in java.text will help with this question. This requires
padding with spaces and nothing in java.text does this. There is no API in
Java that does this, primarily because it is almost always used in a
non-portable way. Aligning with spaces assumes that the viewer of that
output will be using a fixed width font, which is a non-portable assumption.
There is no guarantee that even at command prompt that a fixed width font
is being used. Not to mention that assuming that there even is a command
prompt is non-portable.

However Sun, did bow to the pressure in JDK1.5 and have added printf style
formatting.
 
N

nos

Dale King said:
do


Actually nothing in java.text will help with this question. This requires
padding with spaces and nothing in java.text does this. There is no API in
Java that does this, primarily because it is almost always used in a
non-portable way. Aligning with spaces assumes that the viewer of that
output will be using a fixed width font, which is a non-portable assumption.
There is no guarantee that even at command prompt that a fixed width font
is being used. Not to mention that assuming that there even is a command
prompt is non-portable.

However Sun, did bow to the pressure in JDK1.5 and have added printf style
formatting.

But will it be like 'c' and not consider character width?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top