Good Evening,
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:
if((index + 1) <= ld_data.size())
{
....
}
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.
if((index - 1) >= (ld_data.size() - ld_data.size()))
{
....
}
In the C# .NET world we have ArrayList.UpperBound or ArrayList.LowerBound is there something similiar in Java?
JB
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.