| Author |
System.out.println Special Characters
|
David Dickinson
Ranch Hand
Joined: Nov 11, 2004
Posts: 66
|
|
Hi, Does the command System.out.println have any special functions which enter tabs into the stream or anything like that? Features which would improve the formatting of the console output? For instance I have multiple lines and wish for the information to be displayed like so.. Report xyz calculates currency exchange �-$ = $120 Report xyz calculates oil price rise to be = $110/day Etc etc so the equals column is always level
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24054
|
|
You can embed a tab in a string using the escape sequence \t -- i.e., System.out.print("\t") prints a tab character.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Mike Gershman
Ranch Hand
Joined: Mar 13, 2004
Posts: 1272
|
|
System.out.println( "oil price" + '\t' + "$50" ); System.out.println( "wine price" + '\t' + "$60" ); Be aware that the number of spaces between tabs could be 5, so hitting the same tab to align columns requires a bit of planning.
|
Mike Gershman
SCJP 1.4, SCWCD in process
|
 |
 |
|
|
subject: System.out.println Special Characters
|
|
|