title: Inserting data into an arraylist
body: <p>My question is specific to Java. I have a Get and Set method that will get and set the data.
  I would like to add this into an arraylist. How can I do this ?</p>
  
  <p>Below I've shown a small sample of what I've done so far. </p>
  
  <pre><code>public class GetSetMethod {
  
      String newcompanyid = null;
  
      public String getNewcompanyid() {
          return newcompanyid;
      }
  
      public void setNewcompanyid(String newcompanyid) {
          this.newcompanyid = newcompanyid;
      }
  }
  </code></pre>
  
  <p>In my MainActivity I am using this object</p>
  
  <pre><code>    public class MainActivity{
         ArrayList&lt;String&gt; bulk = new ArrayList&lt;String&gt;();
  
         GetSetMethod  objSample = new GetSetMethod();
  
         objSample.setNewcompanyid(newcompanyid);
      }
  </code></pre>
  
  <p>How can I put the values of objSample into the array list. I've tried using </p>
  
  <pre><code>bulk.add(newcompanyid);
  </code></pre>
  
  <p>But since I've a large amount of data to be passed (and there is a for loop also), it calls the function many times. </p>
  
  <p>Thanks for your help !</p>