• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding System.out.printf method

 
Swapnil Suryakant Prabhavalkar
Greenhorn
Posts: 23
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Cheers,
Swapnil
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic