Java List Remove remove(List list, T value)

Here you can find the source of remove(List list, T value)

Description

remove

License

Open Source License

Declaration

public static <T> boolean remove(List<T> list, T value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.List;
import java.util.Set;

public class Main {
    public static <T> boolean remove(List<T> list, T value) {
        if (list == null || value == null) {
            return false;
        }//w w w . j  a v a 2 s  .com
        for (T t : list) {
            if (t.hashCode() == value.hashCode()) {
                list.remove(t);
                return true;
            }
        }
        return false;
    }

    public static <T> boolean remove(Set<T> set, T value) {
        if (set == null || value == null) {
            return false;
        }
        for (T t : set) {
            if (t.hashCode() == value.hashCode()) {
                set.remove(t);
                return true;
            }
        }
        return false;
    }
}

Related

  1. remove(List list, int index)
  2. remove(List list, int index)
  3. remove(List list, int index, T defaultValue)
  4. remove(List list, int position)
  5. remove(List list, T remove)
  6. remove(Object o, List oldList)
  7. removeAfter(List children, int index)
  8. removeAll(List list, Object[] elements)
  9. removeAll(List list, List objects)