This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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: 20038

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!