format() および printf メソッドを使用した文字列の書式設定は初めてです。Oracle サイトのチュートリアルを読みましたが、非常にわかりにくいと思います。そこで、いくつかの例を試してみることにしました。私はこのサンプルを取得し、出力を次のように理解しました124.00
public class TestStringFormatter {
public static void main(String[] args){
/* I do understand % - denotes start of instruction
, is the flag
6 - denotes width
2 - Denotes precision
f - Type */
String s = String.format("%,6.2f",124.000) ;
System.out.printf(s);
}
}
私が理解できないのは、フラグであり、このフォーマットでどのように使用されているのですか? この例で、誰かがフラグ「、」の使用を説明できますか?