If I use a break statement, it will only break inner loop and I need to use some flag to break the outer loop. But if there are many nested loops, the code will
break
One way is to put all the nested loops into a function and return from the inner most loop incase of a need to break out of all loops.
function() { for(int i=0; i<1000; i++) { for(int j=0; j<1000;j++) { if (condition) return; } } }