Java Array Has inArray(String str, String[] stringArray)

Here you can find the source of inArray(String str, String[] stringArray)

Description

in Array

License

Apache License

Declaration

public static boolean inArray(String str, String[] stringArray) 

Method Source Code

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

public class Main {

    public static boolean inArray(String str, String[] stringArray, boolean caseInsensetive) {
        return getInArrayID(str, stringArray, caseInsensetive) >= 0;
    }//from www  .  j a  va  2s  .c  o  m

    public static boolean inArray(String str, String[] stringArray) {
        return inArray(str, stringArray, false);
    }

    public static boolean inArray(String str, String stringArray, String strsplit, boolean caseInsensetive) {
        return inArray(str, stringArray.split(strsplit), caseInsensetive);
    }

    public static boolean inArray(String str, String stringArray, String strsplit) {
        return inArray(str, stringArray.split(strsplit), false);
    }

    public static boolean inArray(String str, String stringArray) {
        return inArray(str, stringArray.split(","), false);
    }

    public static int getInArrayID(String strSearch, String[] stringArray, boolean caseInsensetive) {
        for (int i = 0; i < stringArray.length; i++) {
            if (caseInsensetive) {
                if (strSearch.toLowerCase().equals(stringArray[i].toLowerCase())) {
                    return i;
                }
            } else {
                if (strSearch.equals(stringArray[i])) {
                    return i;
                }
            }

        }
        return -1;
    }

    public static int getInArrayID(String strSearch, String[] stringArray) {
        return getInArrayID(strSearch, stringArray, true);
    }
}

Related

  1. inArray(int[] arr, int search)
  2. inArray(int[] array, int needle)
  3. inArray(Object[] ps, Object p)
  4. inArray(String arg, String[] array)
  5. inArray(String needle, String... haystack)
  6. inArray(String string, String[] strings)
  7. inArray(String value, String[] s)
  8. inArray(String value, String[] values)
  9. inArray(String[] attributes, String attribute)