• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

System.out.print questions

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic