Here you can find the source of containsString(String stringToCheck, Collection
Parameter | Description |
---|---|
stringToCheck | the given string. |
collection | the given collection of type String . |
public static boolean containsString(String stringToCheck, Collection<String> collection)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { /**//from w w w. ja v a 2 s . c om * Checks if a given collection of strings already contains a given string. * * @param stringToCheck * the given string. * @param collection * the given collection of type {@link String}. * @return {@code true} in case the collection contains the given string, {@code false} * otherwise. */ public static boolean containsString(String stringToCheck, Collection<String> collection) { for (String item : collection) { if (item.equals(stringToCheck)) { return true; } } return false; } }