What is the "continue" keyword and how does it work in Java?

faceless1_14 picture faceless1_14 · Dec 23, 2008 · Viewed 490.4k times · Source

I saw this keyword for the first time and I was wondering if someone could explain to me what it does.

  • What is the continue keyword?
  • How does it work?
  • When is it used?

Answer

Dustin picture Dustin · Dec 23, 2008

continue is kind of like goto. Are you familiar with break? It's easier to think about them in contrast:

  • break terminates the loop (jumps to the code below it).

  • continue terminates the rest of the processing of the code within the loop for the current iteration, but continues the loop.