Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision |
student:java:formatting [2018/08/10 13:08] – bernstdh | student:java:formatting [2018/08/10 13:09] (current) – bernstdh |
---|
Format specifiers have the following syntax. | Format specifiers have the following syntax. |
| |
%[//flags//][//width//][.//precision//]//conversion// | | %[//flags//][//width//][.//precision//]//conversion// | |
| |
Common values of //conversion// include ''%%b%%'' for ''%%boolean%%'', ''%%c%%'' for ''%%char%%'', ''%%d%%'' for ''%%int%%'', ''%%e%%'' for ''%%double%%'' in scientific notation, ''%%f%%'' for ''%%double%%'', and ''%%s%%'' for ''%%String%%''. | Common values of //conversion// include ''%%b%%'' for ''%%boolean%%'', ''%%c%%'' for ''%%char%%'', ''%%d%%'' for ''%%int%%'', ''%%e%%'' for ''%%double%%'' in scientific notation, ''%%f%%'' for ''%%double%%'', and ''%%s%%'' for ''%%String%%''. |
The format string in the invocation of the ''%%format()%%'' method should have the same number of format specifiers as there are other parameters in the invocation. This is illustrated in the following example. | The format string in the invocation of the ''%%format()%%'' method should have the same number of format specifiers as there are other parameters in the invocation. This is illustrated in the following example. |
| |
<code> | <code java> |
int year = 2017; | int year = 2017; |
double sales = 1050987.00; | double sales = 1050987.00; |