title: Breaking out of nested if
body: <p>I have a bit of code that contains nested if statements:</p>
  
  <pre><code>if(numberOfNeighbors == 1){
  
                  //go through comparison again, add Pixel(i,j) to current linked list -&gt; complist[numberOfComponents]
                      //  break out of large check ??
  
                      if(ji.getPixelColor(i, j) == (ji.getPixelColor(i-1,j-1))){ //compare to top left
                          complist[numberOfComponents].addFirst(new Pixel(i,j,numberOfComponents)); break; 
                      }
                      if(ji.getPixelColor(i, j) == (ji.getPixelColor(i,j-1))){ // compare to top
                          complist[numberOfComponents].addFirst(new Pixel(i,j,numberOfComponents)); break;
                      }
  
                      if(ji.getPixelColor(i, j) == (ji.getPixelColor(i+1,j-1))){ // compare to top right
                          complist[numberOfComponents].addFirst(new Pixel(i,j,numberOfComponents)); break;
                      }
                      if(ji.getPixelColor(i, j) == (ji.getPixelColor(i-1,j))){ // compare to left
                          complist[numberOfComponents].addFirst(new Pixel(i,j,numberOfComponents)); break;
                      }
  } // end of if(numberOfNeighbors == 1)
  </code></pre>
  
  <p>Basically what I would like to do, however inefficient this may be, is compare a something 4 times, but if it turns out it is a match, break out of the set of the 4 nested if statements, as well as the outer if statement.</p>
  
  <p>Will this work? or will it just break out of the nested if its currently at and continue to the next until its gone through all 4?</p>