• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.out.println Special Characters

 
David Dickinson
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can embed a tab in a string using the escape sequence \t -- i.e.,

System.out.print("\t")

prints a tab character.
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic