File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Formatting doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Formatting doubt" Watch "Formatting doubt" New topic

Formatting doubt

sentil kumar
Ranch Hand

Joined: Oct 23, 2006
Posts: 74
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

Joined: Nov 06, 2006
Posts: 32

<a href="" target="_blank" rel="nofollow"></a>
Henry Wong

Joined: Sep 28, 2004
Posts: 20538

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.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: Formatting doubt
It's not a secret anymore!