Search⌘ K

The Class DecimalFormat

Explore how to use the DecimalFormat class in Java to format numeric output. Understand creating patterns for digits, decimals, percentages, and currency symbols, and learn to control displayed decimal places for clear and professional program output.

We'll cover the following...

Program output so far

Up to now, we have had little control over the format of output from println statements. For example, when we display a real value, the number of places shown after the decimal point is left to the system to choose. Sometimes that is good enough, but other times we always will want a certain number of digits to appear. We’ll look at a class in the ...