"\t" will automatically take a tab, so if you need less space open, you shouldn't use that. you may try by replacing the "\t" with a couple of spaces, or try formatted output.
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
Well, don't just use spaces on your own.
Try formatting as he suggested. Take a look at
String.format()
to format the String before output or
PrintStream.printf()
to format the String during output (System.out is a PrintStream if it is System.out that you are using).
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
Hi Masijade,
Could you please help me in understanding the String.format() more closely. I am in urgent need. Could you help by giving some examples.
Thanks,
Ashok.
the api's are allways a good place to start, otherwise there's allways google .
the intention of this forum is to learn for yourself, with guidance from part of the other users. by making mistakes and have other people looking into it, not by letting other people write you the code you want to have.
look into the api's and check how it works, try writing what you want it to do and if it still does not give you the result you need, post your code and error here.
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
Hi Masijade,
Could you please help me in understanding the String.format() more closely. I am in urgent need. Could you help by giving some examples.
Thanks,
Ashok.
Read this carefully http://java.sun.com/javase/6/docs/api/java/util/Formatter.html#syntax
And then, as already said, attempt to do it yourself, if you have problems post what you have and we will attempt to help you correct it. And that link contains examples and a complete explanation of the format string to be used in the format method, so it will contain more than enough information for you to be able to accomplish your task.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
Then you're going to have to reproduce the results yourself.
Take a look at the values to be written into each field, find the longest, and pad the rest in that column to match it.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494