I have an ArrayList having 30 elements includes null also at some positions, and I am sequentially accessing the ArrayList. Now I want to check whether index contains null element or not. How to avoid IndexOutOfBoundsException so that I can perform some business logic if null element found, list.size() > index won't help in this case.
PS : I don't want to remove null and want to keep position intact. Yes I can perform business logic in catch(IndexOutOfBoundsException){} block also but is there any other way other than try/catch block because I think it is not performant.