concept index in category java

This is an excerpt from Manning's book Java SE 11 Programmer I Certification Guide.
Because the last character is placed at index 3, the following code will throw an exception at runtime:
Method addAll(int index, Collection<? extends E> c) inserts all the elements in the specified collection into this list, starting at the specified position.

This is an excerpt from Manning's book JUnit in Action, Second Edition.
This discussion applies to all methods that return a List: getAnchors, getForms, and getFrames. You should consider the implication of addressing these lists with indexes. For example, consider the following snippet:
HtmlForm form = page.getForms().get(0);The index access creates an assumption in your test that the HTML form you want to test will always be the first form in the list. If the page changes and the search form changes position, your test will fail, even though the page’s functionality may not have changed. By addressing the form by index, you’re explicitly testing the form order on the page. Address an element only through a list index if you want to test the order of an element in that list.