Here you can find the source of containsInstance(Collection collection, Object element)
Parameter | Description |
---|---|
collection | the Collection to check |
element | the element to look for |
public static boolean containsInstance(Collection collection, Object element)
//package com.java2s; import java.util.Collection; public class Main { /**//from ww w. j a v a 2 s . co m * Check whether the given Collection contains the given element instance. * <p>Enforces the given instance to be present, rather than returning * {@code true} for an equal element as well. * @param collection the Collection to check * @param element the element to look for * @return {@code true} if found, {@code false} else */ public static boolean containsInstance(Collection collection, Object element) { if (collection != null) { for (Object candidate : collection) { if (candidate == element) { return true; } } } return false; } }