This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Not able to understand the output Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Not able to understand the output" Watch "Not able to understand the output" New topic
Author

Not able to understand the output

Abhilash Sharma
Ranch Hand

Joined: Dec 05, 2010
Posts: 67

Please tell me how these statement-:

System.out.printf("12%1$s","13%1$s","14%1$s"); and System.out.printf("12%1$s","13%1$s","14%1$s","15%1$s");

produce same output-:

1213%1$s


OCPJP 6 | OCEJWCD 6
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16692
    
  19

Anishashu Sharma wrote:Please tell me how these statement-:

System.out.printf("12%1$s","13%1$s","14%1$s"); and System.out.printf("12%1$s","13%1$s","14%1$s","15%1$s");

produce same output-:

1213%1$s


Well, it becomes obvious by reading the documentation -- java.io.PrintStream and java.util.Formatter.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Abhilash Sharma
Ranch Hand

Joined: Dec 05, 2010
Posts: 67

Thanks.I got it.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Not able to understand the output
 
Similar Threads
Regarding System.out.printf method
Please explain the output of this: This question is from ExamLabs Diagnostic Test
examlab diagnostic test question 10
Doubt in a practise question
What is the output of printf?