gpt4 book ai didi

java while 循环没有按预期工作

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

我正在使用 while 循环来运行逻辑,直到两个 int 值相同。下面是代码,编译器执行 while 条件,它会跳过。

        while(paramCnt == threshold_value){
ps.setString(paramCnt++, "abc");
}

paramCnt 值小于 threshold_value 时代码不工作。我想运行它直到两个值相等。

我不确定我哪里做错了。任何帮助表示赞赏。

最佳答案

while 循环在条件为真时执行括号之间的代码。你的情况从一开始就不成立。为了循环直到两个值相等,您可以将条件更改为:

while(paramCnt != threshold_value){
...
}

现在您将循环直到 paramCnt 和 threshold_value 相等。

关于java while 循环没有按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51853947/

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