Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.out.print questions

 
Richard Chambers
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is beyond basic, but here goes.

We've studied ONLY the System.out.print methods of displaying output,
so I'll have to use one of those, I know there are other better ways.

My formatted output will look similar to a spreadsheet.

It will have 10 columns spanning 105 spaces.

I'm planning on using printf

my question has to do with cell spacing

We've done things like the $%10.2f for money,
is there a limit to my width?
or in other words, is %30s a valid entry?
also, how do I adjust my console window to display the 105 spacing,
currently my trial runs are truncating.

just checking before I type it in a few hundred times in the actual coding

Thanks
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Richard Chambers:
...how do I adjust my console window to display the 105 spacing,
currently my trial runs are truncating...

On a Windows Command Prompt in XP, you can right-click on the title bar, then select "Defaults" or "Properties." On the "Layout" tab, you can set the screen buffer size (the "actual" size of the console) and the window size (the scrolling frame that you're using to view the console).
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Richard Chambers:
just checking before I type it in a few hundred times in the actual coding


On a side note, rather than type it in a few hundred times, you might want to create a little utility method which formats whatever you put into it however you want it.

Not sure what you're typing, of course, but it is usually a good idea to be lazy about duplication.

I've heard it stated something like this:
the first time you write it, just write it.
the second time you write it, go ahead and write it, or copy and paste it and tweak it to what you need.
the third time you write it, abstract it into a method and replace the two previous instances with your new method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic