Reputation: 319
I am using while
loop to run the logic until both the int values are same.below is the code and compiler executes the while condition, it skips.
while(paramCnt == threshold_value){
ps.setString(paramCnt++, "abc");
}
code is not working when paramCnt
value is less than threshold_value. I want to run it until both values are equal.
I was not sure of where i am doing wrong. any help is appreciated.
Upvotes: 1
Views: 65
Reputation: 303
A while loop executes the code between it's brackets while a condition is true. Your condition is not true from the start. In order to loop until both values are equal you could change your condition to:
while(paramCnt != threshold_value){
...
}
Now you would be looping until paramCnt and threshold_value are equal.
Upvotes: 3
Reputation: 27812
If you want to loop until they equal, it means keep looping if they don't equal:
while(paramCnt != threshold_value){
ps.setString(paramCnt++, "abc");
}
Upvotes: 2