Home >Java >javaTutorial >An example to help you understand the difference between break and continue
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); } } }
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!