0

System.out.printf - 標準出力関数の間に新しい行を配置する他の方法があることを教えてください。

  package formattedoutput;

  public class FormattedOutput {

    public static void main(String[] args) {

        double  amount;
        amount = 43.676;
        int spaces;
        spaces = 77;


        System.out.printf( "%1.2f", amount );// the "2" in 1.2 specifies the number of digits to use after the decimal point. 
        System.out.println();
        System.out.printf("%12d", spaces ); // specifies the minimum number of spaces that should be used for the output. If the integer that is being output takes up fewer than 12 spaces, extra blank spaces are added in front of the integer to bring the total up to 12.
    }

  }
4

1 に答える 1

3

%nおそらく、フォーマット文字列の最後に追加したいだけでしょう。

于 2014-02-14T22:49:30.373 に答える