Take the 2-minute tour ×

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' ?

share|improve this question

closed as not constructive by Oded, Charles Salvia, Robert Harvey, GrandmasterB, Dynamic Dec 20 '12 at 21:14


Apart from the legacy of C? Why do you think "skip" is more straight forward than "continue"? Why not "jump over"? Why not "do again"? –  Oded Dec 18 '12 at 11:07
@Oded Yup, it could be anything. 'skip' was just an example. –  Krishnaraj Dec 18 '12 at 13:11

3 Answers 3

up vote 16 down vote accepted

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.

share|improve this answer
The problem with next is that in some languages (e.g. Basic) next is the end of a for loop, so it might be confusing for some programmers with a background in those languages. –  user281377 Dec 18 '12 at 11:07
stopCurrentActionAndContinueProcessingFromTheNextItemInThisLoop; –  Juha Untinen Dec 18 '12 at 11:40
@user281377: Do any languages other than BASIC use next to mark the end of a for loop? –  Keith Thompson Dec 18 '12 at 11:57
@JuhaUntinen perfect! And thanks to modern IDEs long names are a problem of the past ;-) –  Simon Dec 18 '12 at 12:55
@Keith: We are all spoiled :) –  thorsten müller Dec 18 '12 at 19:39

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.

share|improve this answer
When you ask someone to continue they usually keep doing what they were doing but here the iteration is skipped. I think 'next' would have been a better suitable keyword as mentioned in the answer. –  Krishnaraj Dec 20 '12 at 18:00

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

The first line introduces a do loop that, when completed, continued execution at label 42.

share|improve this answer
It's ironic that other languages would borrow the statement from a language where it was a no-op. I wonder how the loops were implemented on the old machines? One DSP I used had an assembly-language instruction that worked like FORTRAN do-loop: one specified the address preceding the instruction following the loop, and it would set a special flag and load a special register with that address following that, and load another special register with the one following the "loop-start" instruction.. Whenever the code-fetch unit read a word from the first special register... –  supercat Mar 27 at 21:23
...and the loop flag it was set, it would load the program counter with the value in the second, decrement a counter, and if it reached zero, clear the loop flag. Like FORTRAN, the DSP forbade branching instructions immediately before the end of the loop (to avoid a pipeline stall, the program counter would get loaded with the loop start address before the last couple instructions were executed, so jumps there would cause confusion). –  supercat Mar 27 at 21:27
