title: How to concat string values in array list
body: <p>I need to print all arraylist values at a time using concat.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>ArrayList&lt;String&gt; lst = new ArrayList&lt;String&gt;();
  lst.add("hi");
  lst.add("hello");
  Iterator&lt;String&gt; itr = lst.iterator();
  String result = null;
  
  while(itr.hasNext()) {
     Object element = itr.next();
     result = element + " ";
  }
  
  System.out.println(result);
  </code></pre>
  
  <p>The expected result should be <code>hi hello</code>.</p>
  
  <p>The current output however is <code>hello</code> (there is also a <em>whitespace</em> at the end).</p>