Java tutorial
//package com.java2s; //License from project: Open Source License import android.support.annotation.Nullable; import java.util.List; public class Main { public static <T> T getOrDefault(List<T> list, int position, @Nullable T defaultValue) { try { return list.get(position); } catch (Exception e) { return defaultValue; } } }