title: Copy elements of a custom arrayList to a String
body: <p>I am trying to put the elements from my custom arrayList to a String. But when i tried to iterate over it, it only prints the last entry. This is for a todolist app that should have the name of the task and either 1 or 0 depending on whether the task is done or not.</p>
  
  <p>This is the code so far:</p>
  
  <p><strong>Entry.java</strong></p>
  
  <pre><code>public class Entry {
  String S;
  boolean b;
  public Entry(String S, boolean b) {
      this.S = S;
      this.b = b;
  }
  public String getS() {
      return S;
  }
  
  public void setS(String S) {
      this.S = S;
  }
  
  public void setB(boolean b) {
      this.b = b;
  }
  
  public boolean isB() {
      return b;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>ArrayList&lt;Entry&gt; mEntries;
  String copy;
  String name1;
  int i;
  public String getShareData() {
  
      for (Entry n : mEntries) {
          name1 = n.getS();
          i = boolToInt(n.isB());
          copy = name1 + "\t" + i + "\n";
      }
      return copy;
  }
  
  public int boolToInt(boolean b) {
      return b ? 1 : 0;
  }
  </code></pre>