Home > Java > javaTutorial > An example to help you understand the difference between break and continue

An example to help you understand the difference between break and continue

怪我咯
Release: 2017-06-26 11:35:49
Original
2104 people have browsed it

public class Test {
  public static void main(String[] args) {
    for (int i = 0; i < 5; i++) {
      if (i == 2)
        // break;
        continue;
      System.out.println(i);
    }
  }
}
Copy after login

Conclusion: break is used to terminate the entire loop, while continue is used to terminate a certain loop.

The above is the detailed content of An example to help you understand the difference between break and continue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template