title: java reading from csv file and storing its information into ArrayList<class>
body: <p>I'm a java newbie and I need a some help</p>
  
  <p>so here is my main method:</p>
  
  <pre><code>RegistrationMethods dmv = new RegistrationMethods();
  ArrayList&lt;CarOwner&gt; ItState = new ArrayList&lt;CarOwner&gt;();
  dmv.processTextToArrayList(ItState);
  </code></pre>
  
  <p>and I have a class called <code>CarOwner</code> and it has getters and setters for <code>firstName, lastName, license, month, year</code> instance variables.</p>
  
  <p>And this is my method header for <code>processTextToArrayList</code> method:</p>
  
  <pre><code>public void processTextToArrayList(ArrayList&lt;CarOwner&gt; inList) throws IOException
  </code></pre>
  
  <p>this method is supposed to add new <code>CarOwner</code> objects to the <code>inList CarOwner</code> collection passed in.  For each line of the csv file,  a <code>CarOwner</code> object is added to <code>inList</code>.  </p>
  
  <p>I have to read from csv file into arraylist
  my csv file contains something like:</p>
  
  <pre><code>Bunny Bugs ACB-123 5 2013
  
  Bunny Honey DEF-456 9 2013
  
  Bunny Lola GHI-789 3 2014
  </code></pre>
  
  <p>how do I code this using while loop? </p>
  
  <p>edit:</p>
  
  <p>my CarOwner class is :</p>
  
  <pre><code>public class CarOwner extends Citizen implements CarOwnerInterface, Serializable
  {
  private String license;
  private int month, year;
  
  public CarOwner()
  {
      super();
      license = "Not Assigned";
      month = 0;
      year = 0;        
  }
  
  public CarOwner(String inFirst, String inLast, String inLicense, int inMonth, int inYear)
  {
      super(inFirst, inLast);
      license = inLicense;
      month = inMonth;
      year = inYear;
  }
  
  public void setLicense(String inLicense)
  {
      license = inLicense;
  }
  
  public String getLicense()
  {
      return license;
  }
  
  public void setMonth(int inMonth)
  {
      month = inMonth;
  }
  
  public int getMonth()
  {
      return month;
  }
  
  public void setYear(int inYear)
  {
      year = inYear;
  }
  
  public int getYear()
  {
      return year;
  }
  
  public int compareTo(Object o)
  {
      if ((o != null ) &amp;&amp; (o instanceof CarOwner))
      {
          CarOwner otherOwner = (CarOwner) o;
          if (otherOwner.compareTo(getYear()) &gt; 0)
              return -1;
          else if (otherOwner.compareTo(getYear()) &lt; 0)
              return 1;
          else if (otherOwner.equals(getYear()))
              if (otherOwner.compareTo(getMonth()) &gt; 0)
                  return -1;
              else if (otherOwner.compareTo(getMonth()) &lt; 0)
                  return 1;
              else if (otherOwner.equals(getMonth()))
                  return 0;
      }
      return -1;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and my Citizen class is also:</p>
  
  <pre><code>public class Citizen implements CitizenInterface, Serializable
  {
  private String firstName, lastName;
  
  public Citizen()
  {
      firstName = "No Name";
      lastName = "No Name";
  }
  
  public Citizen(String inFirstName, String inLastName)
  {
      firstName = inFirstName;
      lastName = inLastName;
  }
  
  public void setFirstName(String inFirst)
  {
      firstName = inFirst;
  }
  
  public String getFirstName()
  {
      return firstName;
  }
  
  public void setLastName(String inLast)
  {
      lastName = inLast;
  }
  
  public String getLastName()
  {
      return lastName;
  }
  
  public String toString()
  {
      String str;
  
      str = firstName + " " + lastName;
  
      return str;
  }
  </code></pre>