Java Array Contain arrayContains(String[] array, String word)

Here you can find the source of arrayContains(String[] array, String word)

Description

Returns whether or not a string can be found in an array of strings.

License

BSD License

Parameter

Parameter Description
array the array to check
word the string to look for

Return

true if found, false otherwise

Declaration

public static boolean arrayContains(String[] array, String word) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    /**/*  w w w . j a  v  a 2 s . com*/
     * Returns whether or not a string can be found in an array of strings.
     * 
     * @param array the array to check
     * @param word the string to look for
     * @return true if found, false otherwise
     */
    public static boolean arrayContains(String[] array, String word) {
        if (array == null)
            return false;
        for (String element : array)
            if (element.equalsIgnoreCase(word))
                return true;
        return false;
    }
}

Related

  1. arrayContains(Object[] haystack, Object needle)
  2. arrayContains(String[] arr, String sg, boolean ignoreCase)
  3. arrayContains(String[] array, String str)
  4. arrayContains(String[] array, String value)
  5. arrayContains(String[] array, String value)
  6. arrayContains(String[] parent, String[] child)
  7. arrayContains(String[] pArray, String pItem)
  8. ArrayContains(String[][] arr, String s)
  9. arrayContains(T haystack[], T needle)