gpt4 book ai didi

Java换行选项

转载 作者:行者123 更新时间:2023-12-01 23:11:59 25 4
gpt4 key购买 nike

你能告诉我是否还有其他方法可以在 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.
}

}

最佳答案

您可能只想将 %n 添加到格式字符串的末尾。

关于Java换行选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21790869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com