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

booleancontainsReference(List references, Object toBeFound)
contains Reference
for (Object reference : references) {
    if (reference == toBeFound) {
        return true;
return false;
booleancontainsSameItemsInOrder(List col1, List col2)
contains Same Items In Order
if (col1 == col2)
    return true;
if (col1 == null || col2 == null)
    return false;
if (col1.size() != col2.size())
    return false;
Iterator<?> it1 = col1.iterator();
Iterator<?> it2 = col2.iterator();
...
booleancontainsStr(List list, String str)
contains Str
for (Iterator<String> i = list.iterator(); i.hasNext();)
    if (((String) i.next()).equals(str))
        return true;
return false;
booleancontainsStringStartingWith(List list, String prefix)
contains String Starting With
for (String s : list) {
    if (s.startsWith(prefix))
        return true;
return false;
booleancontainsSubsequence(List a, List b)
Determines whether a given list contains another list as a subsequence.
if (b.size() > a.size())
    return false;
outer: for (int i = 0, maxi = b.size(); i < maxi; i++) {
    for (int j = i, maxj = a.size(); j < maxj; j++) {
        if (a.get(j).equals(b.get(i))) {
            continue outer;
    return false;
return true;
booleancontainsType(List list, Class type)
contains Type
return (indexOfType(list, type) != -1);
booleancontainsUnorderedSequence(List a, List b)
contains Unordered Sequence
int remaining = a.size() - b.size();
for (int i = 0; i < remaining; i++)
    if (a.subList(i, i + b.size()).containsAll(b))
        return true;
return false;
booleancontainsUsingToArray(List list, Integer value)
contains Using To Array
boolean found = false;
Object[] a = list.toArray();
for (int i = 0; i < a.length; ++i) {
    if (a[i].equals(value))
        found = true;
return found;
booleancontainsWhitespace(List elements)
contains Whitespace
Iterator itr = elements.iterator();
while (itr.hasNext()) {
    String element = (String) itr.next();
    if (element.trim().equals("")) {
        return true;
return false;
...
StringfirstFunnyString(List words, String containedTest)
first Funny String
String res = words.stream().map(String::toUpperCase).filter(s -> s.length() < 7)
        .filter(s -> s.contains(containedTest)).findFirst().orElse(null);
return res;