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

booleancontainsIgnoreCase(List list, String s)
Returns true if the passed list contains the passed String s, ignoring case.
for (String string : list) {
    if (string.toLowerCase().equals(s.toLowerCase())) {
        return true;
return false;
booleancontainsIgnoreCase(List list, String soughtFor)
contains Ignore Case
for (String current : list) {
    if (current.equalsIgnoreCase(soughtFor)) {
        return true;
return false;
booleancontainsIgnoreCase(String str, String... list)
contains Ignore Case
if (list != null && list.length != 0) {
    for (String s : Arrays.asList(list)) {
        if (s != null && s.equalsIgnoreCase(str)) {
            return true;
return false;
...
booleancontainsInAnyOrder(final List test, final List control)
Compares the content of the two list, no matter how they are ordered
if (test == null || control == null) {
    return false;
if (test.size() != control.size()) {
    return false;
final List<T> orderedControl = new LinkedList<T>(control);
Collections.sort(orderedControl);
...
booleancontainsIndex(int index, List objects)
Determines whether the specified index is not null in the specified list.
if (objects.size() >= index) {
    for (int i = 0; i < objects.size(); i++) {
        if (i == index) {
            return true;
return false;
...
booleancontainsInEach(List first, List second)
Contains in each.
for (String value : second) {
    if (!first.contains(value)) {
        return false;
return true;
BooleanContainsInList(String list, String value)
Contains In List
if (list == null) {
    return false;
} else {
    return Arrays.asList(list.split(",\\s*")).contains(value);
booleancontainsInOrder(List a, List b)
contains In Order
int lastMatch = -1;
for (int i = 0; i < b.size(); i++) {
    T find = b.get(i);
    boolean found = false;
    for (int k = lastMatch + 1; k < a.size(); k++) {
        if (a.get(k).equals(find)) {
            lastMatch = k;
            found = true;
...
booleancontainsInstance(final List list, final Class clazz)
contains Instance
return list.stream().anyMatch(e -> clazz.isInstance(e));
booleancontainsInstance(List list, Object object)
Returns true if the list contains the exact instance of the specified object.
return indexOfInstance(list, object) > -1;