Java Utililty Methods Collection Contain

List of utility methods to do Collection Contain

Description

The list of methods to do Collection Contain are organized into topic(s).

Method

booleancontains(C collection, K key)
Type-safe contains
return collection.contains(key);
booleancontains(Collection c, Object o, Comparator comparator)
checks whether the object o is contained in the collection c
if (comparator == null) {
    return c.contains(o);
} else {
    for (Object o2 : c) {
        if (comparator.compare(o, o2) == 0) { 
            return true;
return false;
booleancontains(Collection coll, Object o, Comparator c)
Answer whether or not coll contains Object o, but not based on equal(), but on compareTo()==0
boolean answer = false;
for (Iterator i = coll.iterator(); i.hasNext() && !answer;) {
    answer = 0 == c.compare(o, i.next());
return answer;
booleancontains(Collection collection, Object object)
contains
return collection.contains(object);
booleancontains(Collection objects, Object o)
contains
if (objects == null || o == null)
    return false;
else
    return objects.contains(o);
booleancontains(Collection searchIn, Object[] find)
contains
for (Iterator iterator = searchIn.iterator(); iterator.hasNext();) {
    Object[] objects = (Object[]) iterator.next();
    if (arraysEquals(objects, find)) {
        return true;
return false;
booleancontains(Collection stringCollection, String value)
Determine if a String is contained in a String Collection
if (stringCollection == null || value == null)
    return false;
if (value.length() == 0)
    return false;
for (Iterator i = stringCollection.iterator(); i.hasNext();) {
    Object o = i.next();
    if (!(o instanceof String))
        continue;
...
booleancontains(Collection collection, A value)
Checks if an input collection contains a given value.
if (collection.isEmpty())
    return false;
for (A item : collection)
    if (item == value)
        return true;
return false;
booleancontains(Collection objectArray, Object element)
contains(Collection, object): checks whether the object is in object collection (create empty collection if the array is null)
if (objectArray == null) {
    objectArray = new ArrayList<Object>();
return objectArray.contains(element);
booleancontains(Collection container, String strSearch)
Test if given string contains any element in the container.
boolean bReturn = false;
if ((container != null) && (!container.isEmpty())) {
    for (Iterator<String> itrElements = container.iterator(); (itrElements.hasNext() && (!bReturn));) {
        if (strSearch.contains(itrElements.next())) {
            bReturn = true;
return bReturn;