<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Using for loop to get all elements in an ArrayList?' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Using for loop to get all elements in an ArrayList?' posted on the 'Java Beginners' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 25 May 2013 08:56:11 -0700</pubDate>
    <lastBuildDate>Sat, 25 May 2013 08:56:11 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Using for loop to get all elements in an ArrayList?</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/427356/427356/using-for-loop-to-get-all-elements-in-an-arraylist/</link>
      <description>Hi,&lt;br /&gt;
&lt;br /&gt;
I'm trying to write a method that will use a for loop to iterate through all the positions in an ArrayList and add them to a String. I then want to return that String outside the for loop. Whenever I do this my for loop is ignored and what I initialised the String with is what is returned instead :S&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
  String wordPos = null;
	  for (int i = 0; i &amp;lt; position.size() - 1; i++)
	  {
		  wordPos = wordPos + position.get(i);
	  }
	  
	  return wordPos;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I hope you can tell me what is going wrong or a better way of doing this.&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/427356/427356/using-for-loop-to-get-all-elements-in-an-arraylist/</guid>
      <pubDate>Sun, 12 Feb 2012 03:03:05 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
    <item>
      <title>Re: Using for loop to get all elements in an ArrayList?</title>
      <link>http://www.programmersheaven.com/mb/java_beginners/427356/427480/re-using-for-loop-to-get-all-elements-in-an-arraylist/#427480</link>
      <description>Maybe you should try to declarate &lt;br /&gt;
wordPos = "";&lt;br /&gt;
And are you sure that you made your ArrayList a "String type".&lt;br /&gt;
I hope this helps you?&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java_beginners/427356/427480/re-using-for-loop-to-get-all-elements-in-an-arraylist/#427480</guid>
      <pubDate>Sat, 18 Feb 2012 05:44:15 -0700</pubDate>
      <category>Java Beginners</category>
    </item>
  </channel>
</rss>