java講座

sample1 substring
sample2 equalsIgnoreCase
sample3 startsWith endsWith
sample4 indexOf lastIndexOf
sample5 split
sample6 format

top
blog

sample6 JAVA講座 文字列関数 format

ここではJAVAのサンプルプログラムを紹介しています。
文字列関数 format は指定したフォーマットで文字列を表現します。



String f1 = String.format("[%8d][%8.3f]",i,fl);
として整数iを8桁で、不動小数flを8]桁小数以下3桁で表現します。

結果は
[ 123456][ 0.000]
となります。