Retrieve string from list if we know the index
<p>Is there a way to retrieve a string from an ArrayList if we know the index of the string we want to retrieve? for example in this string:   </p>

<pre><code>String text2 = "if(AGE_Y&gt;15){\r\n"
                + "x=PROPERTY_LENGTH;\r\n"
                + "}";
</code></pre>

<p>The list this string is added to would look like : <code>if, (, AGE_Y, &gt;, 15, ), {, ...</code></p>

<p>Now if we loop through the list and add each item to a StringBuilder and define the index for each item: </p>

<pre><code>for (int i = 0; i &lt; list.size(); i++)
{
   a=list.get(i);
   strBuilder.append(a); 
   index = strBuilder.length() - a.length();
}
</code></pre>

<p>We will know  exactly at what index we have the string "PROPERTY_LENGTH" for example.</p>

<p>My question is, how can we retrieve the string "x" from the List? I'm asking because at the line above "x"(or whatever that variable will be named) I want to insert something else in the StringBuilder. Normally we could do something like:</p>

<pre><code> String previous=list.get(indexOfPropertyLength-2);
 strBuilder.insert(index-previous.length-1,"string to insert");
</code></pre>

<p>Is this at all possible?</p>
