/* ----------------------------------------------------- 整数の表示(桁数・書式指定) Print_int_keta ----------------------------------------------------- */ import java.text.*; class Print_int_keta { public static void main(String[] args ) { int kazu=12345; System.out.print("変数kazuの値をそのまま表示します\n"); System.out.print(kazu); System.out.print("\n\n"); System.out.print("変数kazuの値を書式指定で表示します\n"); System.out.print("----+----1----+----2----+----3\n"); DecimalFormat fm1=new DecimalFormat("#,###"); DecimalFormat fm2=new DecimalFormat("0000000000"); DecimalFormat fm3=new DecimalFormat("\\#"); DecimalFormat fm4=new DecimalFormat("\\#,###"); System.out.print(fm1.format(kazu)); System.out.print("\n"); System.out.print(fm2.format(kazu)); System.out.print("\n"); System.out.print(fm3.format(kazu)); System.out.print("\n"); System.out.print(fm4.format(kazu)); System.out.print("\n"); } }