Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

very easy question

Name: Anonymous 2006-12-09 12:27

hay guys, easy java question:

if I'm displaying a string to standard output, how would i go about lining up the rows.. an example would be

displayname1isthislong      45   34
displayname2isshort       45   34

displayname1 and 2 are output using a toString method for an object within a loop, so I can't just pad out each row individually to get the length i want..

I'm probably making this waay harder than it should be..

Name: Anonymous 2006-12-09 12:31

Java probably has some printf type thing, but if you want to do it by hand, just measure the string length. In pseudocode:

X = witdh of text (maximum)

print text
print Repeat(" ", X - length(text))
print rest

Name: Anonymous 2009-01-14 14:18

JAVA fails

Name: Anonymous 2009-03-06 5:38

The topic Or is   masses of electrical   tape a Maggie   Simpson hologram and?

Name: Anonymous 2010-12-25 23:19

Name: Anonymous 2011-02-03 3:14

Name: Sgt.Kabu꨼kiman㩅ㇸ 2012-05-28 21:09

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List