How do i format text in java. for example i have firstname and lastname. how can i format the text to make it look like lastname is on its column.
instead of looking like:
John Brown
Peter Pan
Jo Jackson
Daniel Liberti
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
How do i format text in java. for example i have firstname and lastname. how can i format the text to make it look like lastname is on its column.
instead of looking like:
John Brown
Peter Pan
Jo Jackson
Daniel Liberti
Last edited by fourseven; May 20th, 2009 at 11:51 PM.
I am a bit confused fourseven,
If this is your input:
John Brown
Peter Pan
Jo Jackson
Daniel Liberti
What does the output look like?
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputationby clicking the
button on their useful posts.
oh sorry, forgot to put that in.
here is how i want it to look like
![]()
You can use tabulator instead of space to align them.
// \t = tab
String name = "John\tBrown" ;
Sometimes you have names that are longer than tab, so you will need to find the length of the longest name and then use it to find out how many tabs you will need to align all of them perfectly.
If you are not presenting this in commando line then another way to do this would be to use labels. One label where first names will stand and another label for last names
Last edited by Dalisra; May 16th, 2009 at 09:59 PM.