java - for each loop with a second boolean parameter -


this question has answer here:

is there here know how this:

boolean condition = true; for(int i=0; i<list.size() && condition; i++){     if (***)         condition = false; } 

with each loop, that:

boolean condition = true; for(string s : list && condition){     if (***)         condition = false; } 

i know second loop not work, have same behaviour without using killing mortal ugly instruction "break".

use break statement:

for(string s: list) {    if (....) {        break;    } } 

btw can kind of loop , imho preferable because more readable.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -