Can u pls tel me hw to right justify, left justify with 80 characters in each line and also do centre alignment a given paragraph in java, pls write me the code for the loop. Thanks a lot in advance
Printable View
Can u pls tel me hw to right justify, left justify with 80 characters in each line and also do centre alignment a given paragraph in java, pls write me the code for the loop. Thanks a lot in advance
Where are the characters being displayed? In a GUI in pixels or on the console by character?
Please post your questions here and not in a private message.
To right adjust a string, you do some simple arithmetic. Get the width of the area to print in and subtract the length of the string to be printed. That is the number of blanks/pixels you need in front of the beginning of the string.