Here you can find the source of containsPrefix(final Collection
Parameter | Description |
---|---|
words | Words to test. |
prefix | Prefix that can appear in the words. |
public static boolean containsPrefix(final Collection<String> words, final String prefix)
//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)); } }