Java Array Contain arrayContainsString(String[] arr, String str, boolean isCaseSensitive)

Here you can find the source of arrayContainsString(String[] arr, String str, boolean isCaseSensitive)

Description

check if a string is included in the array index numbers follow the convention of substring

License

Open Source License

Parameter

Parameter Description
arr a parameter
str a parameter
isCaseSensitive a parameter

Return

true if str isn't null and is found in arr, false otherwise

Declaration

public static boolean arrayContainsString(String[] arr, String str, boolean isCaseSensitive) 

Method Source Code

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

public class Main {
    /**//w ww .j a  v  a  2 s  . c  o m
     * check if a string is included in the array
     * index numbers follow the convention of substring
     * @param arr
     * @param str
     * @param isCaseSensitive
     * @return true if str isn't null and is found in arr, false otherwise
     */
    public static boolean arrayContainsString(String[] arr, String str, boolean isCaseSensitive) {
        boolean found = false;
        if (arr != null)
            for (int i = 0; i < arr.length && !found; i++) {
                if (arr[i].equals(str) || (!isCaseSensitive && arr[i].equalsIgnoreCase(str)))
                    found = true;
            }
        return found;
    }
}

Related

  1. arrayContainsLower(String[] lemmas, String string)
  2. arrayContainsOK(final byte[] b)
  3. arrayContainsOnlyIgnoreCase(String[] array, String... strs)
  4. arrayContainsOverlap(Object[] array1, Object[] array2)
  5. arrayContainsPartKey(String[] array, String key)
  6. arrayContainString(String[] arrayString, String str)
  7. arrayIntContainsInt(int[] arrayInt, int value)