title: Delete array element - move all elements down one index
body: <p>I have code which allows a user to delete an element from an array that they select however I then want to move all existing elements "down one" so there are no gaps left in the array.</p>
  
  <p>At the moment if I delete the first element (index 0) it is deleted but if I add information to the array it is entered at index 1 and index 0 is left null. If something is deleted from an index which has information in the following indices how can I move all the information down one index? </p>
  
  <p>My delete method:</p>
  
  <pre><code>  static void deleteStudent() {
      System.out.println("Wish student would you like to delete?");
      for(int i=0;i&lt;9;i++) {
        System.out.println(i + ": " + studentNamesArray[i]);
      }
      int studentChoice = input.nextInt();
      for(int i = studentChoice+1; i&lt;studentNamesArray.length; i++) {
        studentNamesArray[i-1] = studentNamesArray[i];
      }
    }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I added four entries to the array:
  <code>[one, two, three, four, null, null, null, null, null, null]</code></p>
  
  <p>I ran then program and tried to delete index <code>[2]</code>, this was successful outputting the following:
  <code>[one, two, four, null, null, null, null, null, null, null]</code></p>
  
  <p>as you can see the the elements where moved down as wanted, the problem is then when I add a value to the array again the deleted index is passed over and the element is entered into the next index, see below:
  <code>[one, two, four, null, newadd, null, null, null, null, null]</code></p>
  
  <p>How can I have the program entering the new value into the correct array?</p>
  
  <p>Add method:</p>
  
  <pre><code>  static void addStudent() {
      if (nameArrayCount &lt; 10) {
        System.out.println("Enter the student's name in the following format - surname, forename: ");
        studentName = input.next();
        studentNamesArray[nameArrayCount] = studentName;
        nameArrayCount = nameArrayCount + 1;
      }
      else if (nameArrayCount == 10) {
        System.out.println("******Array is full, please delete a student before adding another.*****");
      }
      if (markArrayCount &lt; 10){
      System.out.println("Enter the first mark: ");
            markOne = input.nextInt();
            System.out.println("Enter the second mark: ");
            markTwo = input.nextInt();
            System.out.println("Enter the third mark: ");
            markThree = input.nextInt();
            studentMarksArray[markArrayCount][0] = markOne;
            studentMarksArray[markArrayCount][1] = markTwo;
            studentMarksArray[markArrayCount][2] = markThree;
            markArrayCount = markArrayCount + 1;
      }
    }
  </code></pre>