title: Read and Add Text File to an ArrayList of Object in Java
body: <p>I have a text file "addresses.txt" that holds information about a person. I have created a Person class and I need to read and store the information from this text file into an ArrayList.
  My error is when trying to read the text file I can not add it to my ArrayList because of the String arguement. Really lost at this point I know it may be a simple solution but I just cant figure it out.</p>
  
  <p>Here is some of my Person class if needed:</p>
  
  <pre><code>public class Person {
  private String firstName;
  private String lastName;
  private String phoneNumber;
  private String address;
  private String city;
  private String zipCode;
  
  private static int contactCounter = 0;
  
  public Person(String firstName, String lastName){
      this.firstName = firstName;
      this.lastName = lastName;
      contactCounter++;
  }
  
  public Person(String firstName, String lastName, String phoneNumber){
      this.firstName = firstName;
      this.lastName = lastName;
      this.phoneNumber = phoneNumber;
      contactCounter++;
  }
  
  public Person(String firstName, String lastName, String address, String city, String zipCode){
      this.firstName = firstName;
      this.lastName = lastName;
      this.address = address;
      this.city = city;
      this.zipCode = zipCode;
      contactCounter++;
  }
  </code></pre>
  
  <p>Here is my main class:</p>
  
  <pre><code>import java.io.*;
  import java.util.Scanner;
  import java.util.ArrayList;
  public class Rolodex {
  
  public static void main(String[] args) {
      ArrayList &lt;Person&gt; contactList = new ArrayList &lt;Person&gt; ();
      readFile(contactList);
  }
  
  public static void readFile(ArrayList &lt;Person&gt; contactList){
      try{
          Scanner read = new Scanner(new File("addresses.txt"));
          do{
              String line = read.nextLine();
              contactList.add(line); //MY ERROR IS HERE. I know why its happening just not how to fix.
          }while(read.hasNext());
          read.close();
      }catch(FileNotFoundException fnf){
          System.out.println("File was not found.");
      }
  }
  </code></pre>