Java Utililty Methods List Remove

List of utility methods to do List Remove

Description

The list of methods to do List Remove are organized into topic(s).

Method

Eremove(List list, int index)
Removes the element at the given index position of a given List instance.
E retval = null;
if (list != null && index >= 0 && list.size() > index) {
    retval = list.remove(index);
return retval;
Eremove(List list, int index)
Removes the item at the given index in the given list.
if (list == null)
    throw new NullPointerException("list must not be null");
if (index < 0)
    index += list.size();
return list.remove(index);
Tremove(List list, int index, T defaultValue)
remove
try {
    return list.remove(index);
} catch (Throwable t) {
    return defaultValue;
Tremove(List list, int position)
remove
if (list.isEmpty()) {
    return null;
return list.remove(position);
Tremove(List list, T remove)
Removes an item from a list and returns the collections instance of this item, or null if not found or the collection is empty/null.
if (isEmpty(list))
    return null;
if (!list.contains(remove))
    return null;
T item = get(list, remove);
list.remove(item);
return item;
booleanremove(List list, T value)
remove
if (list == null || value == null) {
    return false;
for (T t : list) {
    if (t.hashCode() == value.hashCode()) {
        list.remove(t);
        return true;
return false;
Listremove(Object o, List oldList)
remove
List newList;
if (oldList == null) {
    newList = new ArrayList(0);
} else {
    newList = new ArrayList(oldList.size()); 
    newList.addAll(oldList);
    newList.remove(o);
return newList;
voidremoveAfter(List children, int index)
Removes all elements after the given index
while (children.size() > index + 1) {
    children.remove(children.size() - 1);
voidremoveAll(List list, Object[] elements)
remove All
if (elements == null) {
    return;
for (int i = 0; i < elements.length; i++) {
    list.remove(elements[i]);
voidremoveAll(List list, List objects)
Removes all objects from list.
for (E object : objects) {
    remove(list, object);