if (index < 0 || index >= array.length) { // Don't use this index. This is out of bounds (borders, limits, whatever). } else { // Yes, you can safely use this index. The index is present in the array. Object element = array[index]; }
См. также:
Обновление: в соответствии с вашим фрагментом кода,
for(int i = 0; i<=name.length; i++) {
Индекс содержит длину массива. Это за гранью. Вы должны заменить <=
на <
.
for(int i = 0; i < name.length; i++) {
Вам не нужно находить реселлер ViewView. Вы можете сделать следующее
@AndroidFindBy (xpath = "//android.widget.Button[@text='Primary Account ']") личный список primaryAccounts;
или
[ 113] @AndroidFindBy (id = "com.ezepay: id / bMakePrimary") private List primaryAccounts;
Затем, чтобы нажать на конкретную кнопку, вы можете сделать следующий щелчок (primaryAccounts.get (index) ));