Java Collection Contain containsPrefix(final Collection words, final String prefix)

Here you can find the source of containsPrefix(final Collection words, final String prefix)

Description

It returns whether at least a word contains the prefix.

License

Open Source License

Parameter

Parameter Description
words Words to test.
prefix Prefix that can appear in the words.

Return

true if some word contains the prefix.

Declaration

public static boolean containsPrefix(final Collection<String> words, final String prefix) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    /**//  w w w . ja v a 2s  .  com
     * It returns whether at least a word contains the prefix.
     *
     * @param words  Words to test.
     * @param prefix Prefix that can appear in the words.
     * @return true if some word contains the prefix.
     */
    public static boolean containsPrefix(final Collection<String> words, final String prefix) {
        return words.stream().anyMatch(word -> word.startsWith(prefix));
    }
}

Related

  1. containsNullsOrEmptyStrings(Collection c)
  2. containsNumber(Collection collection, Number number)
  3. containsObject(Collection c, T o)
  4. containsObjectIdentity(Collection collection, Object object)
  5. containsOne(final Collection sup, final Collection parts)
  6. containsPrefix(String str, Collection prefixes)
  7. containsSafe(Collection collection, V value)
  8. containsSame(Collection first, Collection second)
  9. containsSameItems(Collection col1, Collection col2)