java - Use array element as termination in for loop -
please explain loop:
for(p=0;p<a[j];p++) i beginner , confused how such loops work?
please emphasize on use of a[j] in loop.
if a[j] remains constant positive number through each iteration of for loop, loop run a[j] times, a[j] evaluates integer (or long, can't tell code posted). of course a[j] (or j) modified inside loop. in case, loop terminates once p greater or equal a[j] when loop condition evaluated. condition checked before each iteration of loop. if a[j] 0 or negative number, contents of for loop never executed. loop can exit prematurely @ time if there call break or return within loop.
Comments
Post a Comment