This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Regarding System.out.printf method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Regarding System.out.printf method" Watch "Regarding System.out.printf method" New topic

Regarding System.out.printf method

Swapnil Suryakant Prabhavalkar

Joined: Feb 25, 2012
Posts: 23

Hi all,

Is System.out.printf method is in syllabus for SCJP 6?

I came across a question in Devaka's examlab software. I am not able to understand the syntax of this method.

The question was: What would be the output of System.out.printf("12%1$s","13%1$s","14%1$s");

I have seen that output comes out to be 1213%1$s but didn't get how.

Could you please explain me?


Oracle Certified Professional, Java SE 6 Programmer (81%), Oracle Certified Expert, Java EE 6 Web Component Developer (87%)
Matthew Brown

Joined: Apr 06, 2010
Posts: 4537

It used to be included - you'd have to check the current syllabus to be sure. Anyway, the explanation of how format strings work is found in the
java.lang.Formatter class documentation (follow the link).
It is sorta covered in the JavaRanch Style Guide.
subject: Regarding System.out.printf method
It's not a secret anymore!