Search results

Java: continue

Quick summary

  • stops current iteration and starts at beginning of loop again

Eclipse example: loops (see example with continue)

Detailed description

The continue statement works within loops. It stops the current iteration of the loop and moves to the next one. The break statement, 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

About Tom Johnson

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, plain language, tech comm careers, and more. Check out my API documentation course if you're looking for more info about documenting APIs. Or see my posts on AI and AI course section for more on the latest in AI and tech comm.

If you're a technical writer and want to keep on top of the latest trends in the tech comm, be sure to subscribe to email updates below. You can also learn more about me or contact me. Finally, note that the opinions I express on my blog are my own points of view, not that of my employer.