Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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
10  
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

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

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

3 Answers

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
2  
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
24  
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
1  
@Keith: We are all spoiled :) – thorsten müller Dec 18 '12 at 19:39
show 2 more comments

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.

share|improve this answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.