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

booleancontainsNone(Collection container, Collection other)
contains None
assert container != null;
assert other != null;
for (T t : other) {
    if (container.contains(t)) {
        return false;
return true;
...
voidcontainsNoNull(final Collection c, final String s)
Checks that the collection does not contain a null value (throws an IllegalArgumentException if it does).
if (c.contains(null)) {
    throw new IllegalArgumentException(s);
CollectioncontainsNoNulls(Collection container)
contains No Nulls
container = checkNotNull(container);
for (T item : container) {
    if (item == null) {
        throw new NullPointerException("Container cannot contain null values");
return container;
booleancontainsNull(Collection collection)
contains Null
if (!isEmpty(collection)) {
    for (Object obj : collection) {
        if (obj == null) {
            return true;
return false;
...
booleancontainsNull(Collection args)
Checks whether the collection contains a null value.
for (Object object : args) {
    if (object == null) {
        return true;
return false;
booleancontainsNull(final Collection c)
contains Null
synchronized (c) {
    for (final Object o : c) {
        if (o == null)
            return true;
    return false;
booleancontainsNullsOrEmptyStrings(Collection c)
Returns true if c contains empty Strings or null references.
for (String s : c) {
    if (isEmptyOrNull(s)) {
        return true;
return false;
booleancontainsNumber(Collection collection, Number number)
contains Number
Iterator<Number> iterator = collection.iterator();
while (iterator.hasNext()) {
    Number comparable = iterator.next();
    if (comparable == null)
        return comparable == number;
    if (comparable.doubleValue() == number.doubleValue())
        return true;
return false;
booleancontainsObject(Collection c, T o)
Checks whether a Collection contains a specified Object.
for (Object o1 : c) {
    if (o == o1) {
        return true;
return false;
booleancontainsObjectIdentity(Collection collection, Object object)
Returns true if the given Collection contains the given object.
return indexOfObjectIdentity(collection, object) >= 0;