title: Delete a record from a list in Java
body: <p>This is my code for deleting a record from a list but I can't seem to get it to work. Any suggestions?</p>
  
  <pre><code>public void deleteRecord (Scanner in)
  {
      int delete = 0;
  
      showRecords();
      System.out.println("Enter the number in the list to delete:");
      delete = in.nextInt();
      delete = delete -1;
      for (int i = delete; i &lt; this.size; i++)
      {
          this.collection[i] = this.collection[i + 1];
          this.collection[size] = null;
          this.size--;
          System.out.println("Record deleted successfully");
          showRecords();
      }
      System.out.println("Please enter a number in the list to delete");
  }
  </code></pre>