wood burning stoves 2.0*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Printf question" Watch "Printf question" New topic
Author

Printf question

Anu Bhagat
Ranch Hand

Joined: Jun 20, 2008
Posts: 64
Hi ,
The following code prints
1213%1$s

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.
Anu



SCJP5.0, SCJA
Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032
Anu,

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: http://aspose.com/file-tools
 
subject: Printf question
 
Similar Threads
examlab diagnostic test question 10
Loops
Doubt in a practise question
Regarding System.out.printf method
Please explain the output of this: This question is from ExamLabs Diagnostic Test