title: IndexOutOfBoundsException: Index -1 out of bounds for length 0
body: <p>I am working on a project given to me for classwork and we are modifying a library system that allows one to addpatrons to the library system, addbooks is already done for me and i have used that as a template to create addpatrons. I have completed it but whenever im trying to create it i get the following error.</p>
  
  <pre><code> IndexOutOfBoundsException: Index -1 out of bounds for length 0
  </code></pre>
  
  <p>Here is where the code is going wrong.</p>
  
  <pre><code>public void execute(Library library, LocalDate currentDate) throws LibraryException {
      int lastIndex = library.getPatrons().size() -1;
      int maxId = library.getPatrons().get(lastIndex).getId();
      Patron patron = new Patron(++maxId, name, phone);
      library.addPatron(patron);
      System.out.println("Patron #" + patron.getId() + " added.");
  </code></pre>
  
  <p>The add patron takes in two values name and phone.</p>
  
  <p>Thanks for your time</p>