title: Why is initialization of nested loop control variables a must in Java?
body: <p>I wrote a simple "find number in multidimensional array" that is included in the official java tutorial. here's the code included in the tutorial:</p>
  
  <pre><code>class LabeledBreak {
      public static void main(String[] args) {
          int [][] numbers = {
              {22, 34, 675, 23, 23},
              {34, 76, 98, 23, 11},
              {65, 234, 87, 23, 76}
          };
  
          int searchFor = 123;
          boolean found = false;
          int i;
          int j = 0;  // &lt;-- this line
  
  search:
          for (i = 0; i &lt; numbers.length; i++) {
                 for (j = 0; j &lt; numbers[i].length; j++) {
                  if (searchFor == numbers[i][j]) {
                      found = true;
                      break search;
                  }
                 }
          }
  
          if (found == true)
              System.out.println("Found " + searchFor + " at index " + i + ", " + j);
          else
              System.out.println(searchFor + " not found!!!");
      }
  </code></pre>
  
  <p>I couldn't understand what's the point of initializing "j" here. I tried removing the initialization statement and make it just a declaration one. But I got that error:</p>
  
  <p>"variable j might not have been initialized"</p>
  
  <p>Why do I have to initialize "j"? why didn't "i" require initialization as well?</p>