Is there any nice way to get the index of the first non-null array element? Yes, you can write
int index; for (int i = 0; i < arr.length; i++) { if (arr[i] != null) { index = i; break; } } but maybe there is some more beautiful way to do this? For example, for getting the first not null element of an array there is a method ObjectUtils.firstNonNull , maybe there is something similar for getting an index?