title: Array element search
body: <p>I am new to java and have been trying to write how to search multidimensional arrays. My code works for elements found but when I enter an element that does not match, it does not printout anything. Please tell me what's wrong with my code.</p>
  
  <pre><code>import java.util.Scanner;
  public class ArraySearch {
  public static void main (String[] args){
      Scanner input = new Scanner(System.in);
  
      //lets create the array
      int [] [] arrayOfInts = {{1, 2,3,4}, {5,6,7,8},{9,10,11,12}};
  
      //create search variables
      System.out.println("Enter the key number to search for in the array: ");
      int key = input.nextInt();
      boolean foundIt;
  
      //perform search using a for loop
      for (int i = 0; i &lt;arrayOfInts.length; i++){
          for (int j = 0; j &lt;arrayOfInts[i].length; j++){
              if (arrayOfInts[i][j] == key) {
                  foundIt = true;
  
                  if (foundIt) {
                      System.out.println("found " + key + " at row " +i+ " column " +j);
  
                  } else {
                      System.out.println(key + "is not in the array");  
                  }
              }
          }
      }
  }
  }
  </code></pre>