title: searching by last name in an array
body: <p>I made a contact list with three classes, the ContactList class holds an array which stores Last Name, First Name, Street, City, State, ZIP, Country, Email, Phone No., and Notes.</p>
  
  <p>I want to implement a search function by last name into the class of ContactList, where it shows all the information of the contact who has the last name the user searched for, but i cant seem to get anything to work. :(</p>
  
  <pre><code>import java.util.*;
  
  public class ContactList {
  
      //declaration of an array and its attributes
      private final int SIZE = 10;
      private Person [ ] list;
      private int nextEmptyElementInArray = 0;
  
      // Constructor for ContactList object
      public ContactList ()   {
          list = new Person [SIZE];
      }
  
      // Method that adds a new contact into the array
      public void addNewContact() {
          list[nextEmptyElementInArray] = new Person();
          list[nextEmptyElementInArray].read();
          nextEmptyElementInArray++;
      }
  
      // Method retrieves contacts by last name
  
      int searchByLastName(Person [] list) {
          Scanner console;
          console = new Scanner(System.in);
          String searchByLastName = console.next();
          for (int i= 0; i&lt; list.length; i++) {
              if (list[nextEmptyElementInArray].lastName.equals(searchByLastName)) 
                  return i;
              }
              return -1;
          }
      }
  </code></pre>