This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

formatting

 
Ankur kothari
Ranch Hand
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
■ "-" Left justify this argument
■ "+" Include a sign (+ or -) with this argument
■ "0" Pad this argument with zeroes
■ "," Use locale-specific grouping separators (i.e., the comma in 123,456)
■ "(" Enclose negative numbers in parentheses



can anyone explain all these things....specially the padding thing or give me a link

thank you
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is explained quite well on page 508 of the K&B book. Its also explained on the Formatter class docs. Try to create some programs to experiment with the things...
 
Ankur kothari
Ranch Hand
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes sir....

means ( removes the - sign and wraps around the number

rest are all clear....nothing better than trying it
 
Ankur kothari
Ranch Hand
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


why is b3 false....
If the argument arg is null, then the result is "false". If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(). Otherwise, the result is "true".

according to this shouldnt it be true?
 
rohan yadav
Ranch Hand
Posts: 156
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankur, I think anything other than true is considered false by Boolean(String) constructor.
So when toString() method gets called for Boolean constructor it returns the "ankur' (in your case). So apart from true anything passed as string to considered as a false
 
Ankur kothari
Ranch Hand
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Otherwise, the result is "true".


what does this mean then?
 
rohan yadav
Ranch Hand
Posts: 156
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means anything you pass to Boolean constructor. Suppose
check out following program


The output is
false
true
false
true

Did you clear what i mean??
 
Ankur kothari
Ranch Hand
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
understood what you are saying...but "otherwise its true" this really confuses me
 
rohan yadav
Ranch Hand
Posts: 156
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry in hurry i typed something weired. Are you preparing for SCJP??
 
Ankur kothari
Ranch Hand
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rohan.....i got what you said...but its the language of the doc that confused me
 
Ankur kothari
Ranch Hand
Posts: 531
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yup i am preparing
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic