Java Utililty Methods Array Contain

List of utility methods to do Array Contain

Description

The list of methods to do Array Contain are organized into topic(s).

Method

booleanarrayContains(Object[] array, Object object)
array Contains
for (int i = 0; i < array.length; i++) {
    try {
        if (array[i] == object || array[i].equals(object)) {
            return true;
    } catch (Exception e) {
return false;
booleanarrayContains(Object[] element, Object[][] array)
array Contains
for (int j = 0; j < array.length; j++) {
    if (Arrays.equals(element, array[j]))
        return true;
return false;
booleanarrayContains(Object[] haystack, Object needle)
Checks if an array contains a certain object
for (Object straw : haystack) {
    if (equals(straw, needle)) {
        return true;
return false;
booleanarrayContains(String[] arr, String sg, boolean ignoreCase)
array Contains
for (int i = 0; i < arr.length; i++) {
    if (ignoreCase) {
        if (sg.equalsIgnoreCase(arr[i]))
            return true;
    } else {
        if (sg.equals(arr[i]))
            return true;
return false;
booleanarrayContains(String[] array, String str)
array Contains
return Arrays.asList(array).contains(str);
booleanarrayContains(String[] array, String value)
Returns true if the given array contains the given value.
for (String potential : array) {
    if (potential.trim().equals(value))
        return true;
return false;
booleanarrayContains(String[] array, String value)
array Contains
if (array == null)
    return false;
for (String element : array) {
    if (element.equals(value))
        return true;
return false;
booleanarrayContains(String[] array, String word)
Returns whether or not a string can be found in an array of strings.
if (array == null)
    return false;
for (String element : array)
    if (element.equalsIgnoreCase(word))
        return true;
return false;
booleanarrayContains(String[] parent, String[] child)
test if all items in parent also appears in child child array will be sorted
if (parent == null || parent.length == 0) {
    return true;
Arrays.sort(child);
for (String i : parent) {
    if (Arrays.binarySearch(child, i) < 0) {
        return false;
return true;
booleanarrayContains(String[] pArray, String pItem)
Check if an array contains a given value.
boolean contained = false;
int i = 0;
while (!contained && i < pArray.length) {
    contained = pArray[i].equals(pItem);
    i++;
return contained;