gpt4 book ai didi

Java println 方法错误

转载 作者:行者123 更新时间:2023-12-01 16:47:21 26 4
gpt4 key购买 nike

我正在尝试打印执行某些方法所需的时间。我用的是

double t0 = 0.01 * System.currentTimeMillis(); I have 3 times like that one. And when I print it like this:

System.out.println("%7d    %10.7f       %10.7f", amount,
(t1 - t0), (t2 - t1));

我收到错误:

no suitable method found for println(String,int,double,double)

这是为什么呢?该字符串参数从哪里来?

最佳答案

您使用了System.out.println(),它不支持像在程序中那样添加参数。使用 System.out.printf() 代替它。

关于Java println 方法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47816997/

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