java - What does $%,.2f represent? -


i reading deitel's book on java, , came across code in 1 of programs:

public string tostring() {   return string.format( "%s: %s\n%s: $%,.2f; %s: %.2f",       "commission employee", super.tostring(),       "gross sales", getgrosssales(),       "commission rate", getcommissionrate() ); } 

as title says, "$%," in front of ".2f" represent? know .2f means.

the $ character means nothing special here. it's literal $ show in string. % character takes it's usual meaning here -- substitute value (here, 2 decimal places).

note it's possible $ character have meaning after % character. please see "argument index" section of formatter javadocs details.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -