Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About String.format()

 
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
Saloon Keeper
Posts: 11178
15
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
Pie
Posts: 50217
79
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic