Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Java by (13.1k points)
Can anyone help me understand what is the continue keyword in Java? And why it is used?

1 Answer

0 votes
by (26.7k points)

Basically, the continue keyword will re-execute the condition for while or do loop and also, update the expression for the for loop. It is usually used for early termination of the loop processing and also comes into play to prevent deeply-nested if statements. You can take the below code as a reference:

while (getNext(line)) {

  if (line.isEmpty() || line.isComment())

    continue;

  // More code here

}

I hope this will help.

Want to become a Java Expert? Join Java Training now!!

Want to know more about Java? Watch this video on Java Tutorial for Beginners | Java Programming :

Related questions

Browse Categories

...