29.1. Introduction

An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss the formatting features of method printf and class Formatter (package java.util). Method printf formats and outputs data to the standard output stream—System.out. Class Formatter formats and outputs data to a specified destination, such as a string or a file output stream.

Many features of printf were discussed earlier in the text. This chapter summarizes those features and introduces others, such as displaying date and time data in various formats, reordering output based on the index of the argument and displaying numbers and strings with various flags.

Get Java™ How to Program, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.