24. Formatted Output


In this chapter you’ll learn:

• To understand input and output streams.

• To use printf formatting.

• To print with field widths and precisions.

• To use formatting flags in the printf format string.

• To print with an argument index.

• To output literals and escape sequences.

• To format output with class Formatter.

All the news that’s fit to print.

Adolph S. Ochs

What mad pursuit? What struggle to escape?

John Keats

Remove not the landmark on the boundary of the fields.



24.1   Introduction

24.2   Streams

24.3   Formatting Output with printf

24.4   Printing Integers

24.5   Printing Floating-Point Numbers

24.6   Printing Strings and Characters

24.7   Printing Dates and Times

24.8   Other ...

Get Java™ for Programmers: Deitel now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.