Как решить задачу, понятно. Вопрос, почему не компилируется? Idea пишет что при таком коде, есть вариант, что result может быть не инициализирован. Но почему? Или тут не все исключения ловятся?
public static int safeGetElement(ArrayList<Integer> list, int index, int defaultValue) {

        int result;

        try{
            result = list.get(index);
        } catch (Exception e) {
            result = defaultValue;
        } finally {
            return result;
        }
}