Java tutorial
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static <E> E removeIfInBounds(final List<E> list, final int index) { return (list != null) && (index >= 0) && (index < list.size()) ? list.remove(index) : null; } }