title: ArrayList of arrays keeps overwriting my previous arrays with the newest array being added
body: <p>Im parsing an xml file.  My XML handler, my object that holds an Arraylist of arrays, and the main class that runs everything and prints it.  The problem is, every time I add an array to my arraylist, it changes the all of the previously added arrays to the same as the current.  I thought it was just a static problem but once I took static out of everything it still is doing the same thing.  Help please I need to have this done asap.</p>
  
  <p>Here is my handler:</p>
  
  <pre><code>import org.xml.sax.Attributes;
  import org.xml.sax.SAXException;
  import org.xml.sax.helpers.DefaultHandler;
  
  public class MyXMLHandler extends DefaultHandler {
  
  public int counter = 0;
  public String[] part = new String[4];
  Boolean currentElement = false;
  String currentValue = null;
  public SitesList sitesList = null; /this used to be static
  
  public SitesList getSitesList() {  //this used to be static
      return sitesList;
  }
  
  public void setSitesList(SitesList sitesList) { //this used to be static
      MyXMLHandler handle = new MyXMLHandler(); //thats why the object
      handle.sitesList = sitesList;
  }
  
  /**
   * Called when tag starts ( ex:- &lt;name&gt;text&lt;/name&gt; -- &lt;name&gt; )
   */
  @Override
  public void startElement(String uri, String localName, String qName,
          Attributes attributes) throws SAXException {
  
      currentElement = true;
  
      if (localName.equals("string-array")) {
          /** Start */
  
          String attr = attributes.getValue("name");
          sitesList = new SitesList(attr);
      }
  
  }
  
  /**
   * Called when tag closing ( ex:- &lt;name&gt;text&lt;/name&gt; -- &lt;/name&gt; )
   */
  @Override
  public void endElement(String uri, String localName, String qName)
          throws SAXException {
      currentElement = false;
  
      /** set value */
      if (counter == 4) {
          sitesList.addPart(part);
          counter = 0;
      }
      if (localName.equalsIgnoreCase("item")) {
          part[counter] = currentValue;
          counter++;
      }
      currentValue = "";
  
  }
  
  /**
   * Called to get tag characters ( ex:- &lt;name&gt;text&lt;/name&gt; -- to get
   * text Character )
   */
  @Override
  public void characters(char[] ch, int start, int length)
          throws SAXException {
  
      if (currentElement) {
          currentValue = new String(ch, start, length);
          currentElement = false;
      }
  
  }
  
  }
  </code></pre>
  
  <p>Here is my SitesList object</p>
  
  <pre><code>import java.util.ArrayList;
  
  /** Contains getter and setter method for varialbles */
  public class SitesList {
  
  /** Variables */
  private ArrayList&lt;String[]&gt; part = new ArrayList&lt;String[]&gt;();
  
  /**
   * In Setter method default it will return arraylist change that to add
   */
  public SitesList(String c) {
      String[] comp = new String[1];
      comp[0] = c;
      part.add(comp);
      // company name is part(0)[0]
  }
  
  public String getCompany() {
      return this.part.get(0)[0];
  }
  
  public ArrayList&lt;String[]&gt; getPart() {
      return part;
  }
  
  public void addPart(String[] name) {
      part.add(name);
  }
  
  public String getName(int i) {
      return this.part.get(i)[0];
  }
  
  public String getComp1(int i) {
      return this.part.get(i)[1];
  }
  
  public String getComp2(int i) {
      return this.part.get(i)[2];
  }
  
  public String getComp3(int i) {
      return this.part.get(i)[3];
  }
  
  public int getSize() {
      return this.part.size();
  }
  
  }
  </code></pre>