Thursday, May 18, 2017

Refresh : If break in inner loop , will it break entire loop?

Sometimes it good to have refreshment.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
for(Integer i=0; i<20 ;i++){

    for(Integer j = 0;j<10;j++){
           system.debug('@@@ j ='+j + 'i ='+i);
        if(j==5){
            system.debug('@@@ FIVE');
            break;
            
        }
        
    }
  
}

Will it break entire loop if inner loop contains break?

As we can see, inner loop will have break at five, but outer loop still continue

No comments:

Post a Comment