For loop Java, please take a look at the zero basis one

CSDN Q & A 2022-02-13 06:29:17 阅读数:305

loop java look zero basis

Why? for(i=1;i<=10;i++) Only cycle 5 Time

Take the answer :

for(i=1;i<=10;i++) Only cycle 5 Not usually , Unless it's yours for Restrictions are added to the loop body
for example
1.if(i==5) break; perhaps while loop , The main reason is that these statements contain return perhaps break perhaps continue key word , The first two of these three are the direct end of the loop , The latter one is to jump out of this cycle , So let's do the next loop
2.for There are changes in the loop i Conditions , such as for(i=1;i<=10;i++){.....i=i+2} such i The value of , Of course, it won't add... At one time 1 了

Other answers 2:

Just this code , Should be for There is also code in the loop, which affects the number of cycles

Other answers 3:

The mistakes that newcomers often make , Two layers of circulation

for (i=1;i<10;i++){




for (i=1;i<10;i++){




Other answers 4:

I think your code should have i++ Relevant code , perhaps break.
Look at the code in your loop .

copyright:author[CSDN Q & A],Please bring the original link to reprint, thank you.