Java Utililty Methods List Contain

List of utility methods to do List Contain

Description

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

Method

voidaddAllIfNotContained(List dst, Collection src)
add All If Not Contained
for (Object object : src) {
    addIfNotContained(dst, object);
voidaddIfNotContained(List list, Object object)
add If Not Contained
if (!list.contains(object)) {
    list.add(object);
booleancontains(final List list, final String str)
contains
for (final String entry : list)
    if (entry.toLowerCase().contains(str.toLowerCase()))
        return true;
return false;
booleancontains(final List requested, final List claimed)
contains
boolean found = false;
for (final String element : requested) {
    if (!claimed.contains(element)) {
        found = false;
        break;
    found = true;
return found;
booleancontains(final List list, T value)
Checks whether the given value is contained within the list (check by value or reference).
for (final T elem : list) {
    if (elem == value || value != null && value.equals(elem)) {
        return true;
return false;
booleancontains(final String text, final List tokens)
Returns whether text contains any of the tokens from the specified list or not.
for (final String token : tokens) {
    if (text.contains(token)) {
        return true;
return false;
booleancontains(final String[] list, final String value)
contains
HashSet<String> set = new HashSet<String>(Arrays.asList(list));
return set.contains(value);
intcontains(int[] list, int x)
contains
int pos = -1;
if (list.length > 10)
    pos = Arrays.binarySearch(list, x);
else
    for (int i = 0; i < list.length; i++)
        if (list[i] == x)
            pos = i;
return pos >= 0 ? pos : -1;
...
booleancontains(int[] match, List container)
Returns a flag indicating whether the container list contains an array which matches the specified match array.
int len = container.size();
for (int i = 0; i < len; i++) {
    if (Arrays.equals(match, container.get(i))) {
        return true;
return false;
booleancontains(int[] subject, int[][] list)
contains
for (int[] row : list) {
    if (Arrays.equals(subject, row)) {
        return true;
return false;