title: How does this delete an element from an array?
body: <p>I am using this book data structures and algorithms in java to learn about (you guessed it) - data structures and algorithms. This piece of code confuses me. I have tested it and it works but i don't see where in the code we specify to delete 55 exactly?</p>
  
  <p>I see that we search for it in the array and move data elements up the index but don't see where we tell the compiler to delete 55.</p>
  
  <pre><code>    searchKey = 55; // delete item with key 55
      for(j=0; j&lt;nElems; j++) // look for it
        if(arr[j] == searchKey)
          break;
      for(int k=j; k&lt;nElems-1; k++) // move higher ones down
        arr[k] = arr[k+1];
      nElems--; // decrement size
  </code></pre>