ArrayList Find First and Last Element
<p>Good Evening,</p>

<p>I have an ArrayList (instantiated as ld_data) and I iterate forward and back looking / displaying to the user the element data. In this process I need to know when I am at the first element and the last. Detecting when I am at the last element I do as such:</p>

<pre><code>if((index + 1) &lt;= ld_data.size())
{
    ....
}
</code></pre>

<p>This works because the size property also is the upper bound of the ArrayList. However detecting when I am at the first element is not as easy for me. The best I've been able to figure out is this which seems rather lame....but it works.</p>

<pre><code>if((index - 1) &gt;= (ld_data.size() - ld_data.size()))
{
    ....
}
</code></pre>

<p>In the C# .NET world we have ArrayList.UpperBound or ArrayList.LowerBound is there something similiar in Java?</p>

<p>JB</p>

<p>EDIT: Further details. So for more information I am bound to a ListView. So when the user has scrolled to the first element of the list I want to show a msg "At start of list" and when they reach the end show "End of list". I know there is a scrollbar that makes this obvious I'm just trying to give an example of what I'm doing. So this check occurs in the "OnScroll" event.</p>
