title: Refactoring nested For-Loops
body: <p>I was trying to refactor a code snippet I found online for a picture program, and I was just wondering if anyone could help me out. The author of the original code chose to use nested for loops, which I know isn't correct. Any ideas to help me work it out?</p>
  
  <pre><code>for (int x = 0; x &lt; this.width(); x++) {
      for (int y = 0; y &lt; this.height(); y++) {
          if (!this.getColor(x, y).equals(typeCastedPicture.getColor(x, y))) {
              return false;
          }
      }
  }
  </code></pre>
  
  <p>I initially just tried using private methods as the solution; however, the problem I'm running into is because it's of type boolean. I'm just not certain how to refactor properly without skewing the semantics. Any help would be greatly appreciated.</p>
  
  <p>The code works 100% correctly as is; however I'm currently using eclipse and the checkstyle flags any time you code in nested blocks. I just wanted to see if any of you guys could help me figure out how to get the same effect without using nested loops.</p>