What is the printf() method?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

What is the printf() method?

Rating:

The printf() method is used to output a formatted string to the console. This method automatically uses the Formatter to create a formatted string. The printf() method is very similar to the format() method present in the Formatter class. This method is present in both the PrintWriter and PrintStream classes.

The printf() method has the following general forms:


  • printf(String fmt, Object...args)
  • : This form writes the args to the standard output in the format specified by fmt. It uses the default locale.

  • printf (Local loc, String fmt, Object...args)
  • : This form allows a user to specify his own locale.
In both the above forms, the return type of the methods can be either the PrintWriter class or the PrintStream class. In both the forms of the printf() method, variable-arguments are used. This is the reason why printf() was not used in the earlier versions of Java, as earlier versions did not support varargs.


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.