Java: continue
Quick summary
- stops current iteration and starts at beginning of loop again
Eclipse example: loops (see example with continue)
Detailed description
The
continuestatement works within loops. It stops the current iteration of the loop and moves to the next one. Thebreakstatement, on the other hand, exits the entire loop. In other words, the continue statement continues the loop, whereas the break statement breaks out of the loop (which explains the origin of these two keywords). The general idiom for its use is that the code in the loop has determined that it does not need to go further and can jump to processing the next item. It’s Java’s way of letting you say, “No, not that one. How about the next one?” Returning to our chessboard, suppose we want to count the number of surviving pawns (see Listing 5-17).
– Java 7 for Absolute Beginners
Sponsored
About Tom Johnson
I'm an API technical writer based in the Seattle area. On this blog, I write about topics related to technical writing and communication — such as software documentation, API documentation, AI, information architecture, content strategy, writing processes, agent skills, tech comm careers, and more. Check out my AI courses for more on the latest in AI and tech comm. If you're looking for info about documenting APIs, see my API documentation course.
If you're a technical writer and want to keep on top of the latest trends in tech comm, be sure to subscribe to email updates below. You can also learn more about me or contact me.
Finally, I want to note a couple of things. I usually write the first drafts of my posts myself and then use AI to improve accuracy, clarity, and detail in places, so my writing is a mix of human and AI. (Hopefully that's not too off-putting.) Also, the opinions I express on my blog are my own perspectives, not those of my employer.