
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Breaking Out of Nested Loop in Java
Yes, break statement can be used in nested for loops. It works on the for loop in which it is applied. See the example below.
Example
public class Tester { public static void main(String[] args) { for(int i = 0; i< 2; i++) { for(int j = 0; j < 2; j++){ if(i == 1) { break; } System.out.println("i = " + i+",j = " + j); } } } }
Advertisements