你能告诉我是否还有其他方法可以在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.
}
}
答案 0 :(得分:3)
您可能只想将%n
添加到格式字符串的末尾。