gpt4 book ai didi

java - String.format 不显示完整消息

转载 作者:行者123 更新时间:2023-11-29 10:00:00 25 4
gpt4 key购买 nike

String Quote = String.format(
"This triangle has an perimeter of %.2f", TP ," and an area of %.2f",TA
);
System.out.printf(Qoute);

下面的代码打印出“

This triangle has an perimeter of 17.94

"并省略了 ","和 %.2f",TA 的区域。我做错了什么?

最佳答案

您提供的格式错误。后面的参数将被视为第一个参数的输入。尝试

String quote = String.format(
"This triangle has an perimeter of %.2f and an area of %.2f",
TP ,TA
);

关于java - String.format 不显示完整消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36312269/

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