Here you can find the source of removeSafe(Collection
public static <V> boolean removeSafe(Collection<V> collection, V value)
//package com.java2s; // under the terms of the Eclipse Public License v1.0 which accompanies import java.util.Collection; import java.util.Map; public class Main { /**/*from w ww . j a va 2 s. c om*/ * Type-safe wrapper for {@link Map#remove(Object)} method. It restricts * type of key and makes sure that you do not try to remove key of wrong * type. */ public static <K, V> V removeSafe(Map<K, V> map, K key) { return map.remove(key); } /** * Type-safe wrapper for {@link Collection#remove(Object)} method. It restricts * type of a value and makes sure that you do not call method for the value * wrong type. */ public static <V> boolean removeSafe(Collection<V> collection, V value) { return collection.remove(value); } }