gpt4 book ai didi

java - 使用 println 时框中的问号

转载 作者:行者123 更新时间:2023-11-30 06:24:58 25 4
gpt4 key购买 nike

在命令提示符下运行此命令时,

System.out.println(Num + " is prime!");
System.out.println("Press N to put in another number or S to stop");

其中 Numint

结果如下:

This is what comes out

有什么办法可以对抗它还是我应该处理它?<​​/p>

最佳答案

System.out.println(String.valueOf(Num) + " is prime!");

编辑:添加更多信息以填补此处的谜团。

java.lang.String.valueOf 将正确解析您的数字,而简单地将数字与字符串相加会因编译器而异。

在此处查看更多信息 Concat an integer to a String - use String literal or primitive from performance and memory point of view?

关于java - 使用 println 时框中的问号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47361725/

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