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 Printf question 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 "Printf question" Watch "Printf question" New topic

Printf question

Anu Bhagat
Ranch Hand

Joined: Jun 20, 2008
Posts: 64
Hi ,
The following code prints

I understand the 1213 portion of the output, but don't undersatnd the rest of the output. Please expain. I read the Java Language documentation but don't get it.

Thanks in advance.

Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032

There is only a format string in the call: "12%1$s". This simply constructs a string with the contents "12" plus the first argument in the argument list using string conversion (basically, creates a string which is "12" concatenated with the second argument of the printf() call.)

All code in my posts, unless a source is explicitly mentioned, is my own.
I agree. Here's the link:
subject: Printf question
jQuery in Action, 3rd edition