0

Out of the two code snippets below, does any of the approach has some benefit over the other?

for(int i:list) {
    if(condition 1) {
      //do something
      continue;
    }
    if(condition 2) {
      //do something
      continue;
    }
    if(condition 3) {
      //do something
      continue;
    }
}

versus

for(int i:list) {
    if(condition 1) {
      //do something
    }
    else if(condition 2) {
      //do something
    }
    else if(condition 3) {
      //do something
    }
}

Do the two approaches differ only in coding style or do we get any performance improvement in one of them.

Faiz Kidwai
  • 463
  • 5
  • 26

0 Answers0