title: Android:ArrayList storing weird values
body: <p>I just don't understand what's going on here.</p>
  
  <pre><code>ArrayList&lt;ListItem&gt; list=new ArrayList&lt;ListItem&gt;();
  ListItem curItem=new ListItem();
  String[] contents=cwFile.list();
  for(int i=0;i&lt;contents.length;i++){
      curItem.itemName = contents[i];
      if(new File(cwd+contents[i]).isDirectory()){
          curItem.isDir=true;
      }
      list.add(i,curItem);
  }
  Log.i("Main",list.get(0).itemName);
  Log.i("Main",contents[0]);
  </code></pre>
  
  <p>So in this code snippet, I get the contents of a directory using the File.list() method</p>
  
  <p>Then, I store the names in an <code>ArrayList</code> of <code>ListItem</code> objects, where <code>ListItem</code> is a self-created class.</p>
  
  <p>But, <code>ListItem</code> is just a class that stores the string</p>
  
  <pre><code>class ListItem {
      protected String itemName ="";
      protected boolean isDir=false;
      protected Double size=0.0;
  }
  </code></pre>
  
  <p>However, after logging the first elements of both the array and the <code>ArrayList</code> (last 2 lines of the first code snippet), I get different results!</p>
  
  <p>This is the log output:</p>
  
  <pre><code>03-15 20:29:46.427 465-465/com.harshal.filer I/filer: .userReturn
  03-15 20:29:46.427 465-465/com.harshal.filer I/filer: Android
  </code></pre>
  
  <p>The second output,"Android" is an actual directory on the device.
  But what's ".userReturn" and where did it come from???</p>