The ‘continue’ keyword in Java (and probably in many other programming languages) is used to skip further execution of the current iteration.
Why was the name ‘continue’ chosen? Why not something more straightforward like ‘skip’ ?
2
While most likely not a very big difference and programmers would have been able to handle it just the same:
“continue” makes it clear that the loop will go on processing data (stop the details, continue the loop), while “skip” could be thought of as terminating the loop totally (like break in C++). It’s one of those cases where it can be difficult to find the “perfect” name for some functionality. Ruby and Perl use “next” in similar situations which to me seems a slightly better choice.
8
I guess it might have to do with history of programming languages.
To ask why it is continue in Java is to ask why it is continue in C++, which is to ask why it is continue in C, Algol etc.
To my knowledge, Fortran was the first to have a CONTINUE statement, actually a no op. It was just there to make it possible to place a (numeric) label used in goto or other constructs like:
DO 42 i=1,100
A[i] = 0
42 CONTINUE
The first line introduces a do loop that, when completed, continued execution at label 42.
3
I always thought of it as just continuing processing data and therefore it was named “continue”. I have never seen anyone have issues with the choice of the continue keyword not being straightforward enough.
1