• Post Reply Bookmark Topic Watch Topic
  • New Topic

Formatting doubt  RSS feed

 
sentil kumar
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.printf("%1$010d, %s",1,111);

output is 0000000001, 1

but my expectedted result is 0000000001, 111

please explain this.
 
Dan Polak
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax
 
Henry Wong
author
Sheriff
Posts: 23280
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not entirely sure, but this may be caused by your use of an argument index. I believe if you don't specify one, it will use some internal index, and that it increments for the next use. When you specified an argument index, it looks like this internal index doesn't change.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!