You need to sign in to do that
Don't have an account?
Anu Raj.ax1269
for loop with more that 1 variable
Is it possible to use more than 2 variable in a for loop.
i tried this
for(integer j=0, k=1; j++,k++) {
}
and getting this error
Error: Compile Error: expecting a right parentheses, found ',' at line 188 column 53
Please help me to find the solution.
Thanks
Anu
Hi,
for(integer a=1,b=5; a<b; a++) {
System.debug('a = ' + a);
System.debug('b = ' + b);
b--;
}
You're missing the condition in the middle of the loop syntax.
But can I ask why you're keeping two variables? The pseudo code looks like you have one variable that is 1 more than the other each iteration. Why not use j+1 inside the loop?