• Post Reply Bookmark Topic Watch Topic
  • New Topic

About String.format()  RSS feed

 
kayanaat sidiqui
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i was going through a blog on java.
I got the guy using String.format().

I could not get why he was using this.

if i write this


Both will give same result i.e. 1.

Is java people included this because of giving feel of c/c++?

Is there any important role of this method?

Thanks,
Kaya.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the API docs for the Formatter class to get a better understanding of the method.
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, it produces Strings similar in format to what is described here in the Java™ Tutorials
 
Roy Paterson
Smart Bear Support
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the example you gave, yes it is pointless. However String.format(...) is capable of much more complicated and useful stuff.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!