Android Array Contains contains(T[] array, T value)

Here you can find the source of contains(T[] array, T value)

Description

contains

Declaration

public static <T> boolean contains(T[] array, T value) 

Method Source Code

//package com.java2s;

public class Main {
    public static boolean contains(int[] array, int value) {
        for (int element : array) {
            if (element == value) {
                return true;
            }//from w  ww.  j  a  v a2  s .  c om
        }
        return false;
    }

    public static <T> boolean contains(T[] array, T value) {
        for (T element : array) {
            if (element == null) {
                if (value == null) {
                    return true;
                }
            } else {
                if (value != null && element.equals(value)) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean equals(byte[] array1, byte[] array2, int length) {
        if (array1 == array2) {
            return true;
        }
        if (array1 == null || array2 == null || array1.length < length
                || array2.length < length) {
            return false;
        }
        for (int i = 0; i < length; i++) {
            if (array1[i] != array2[i]) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. contains(Object[] array, Object objectToFind)
  2. contains(T[] array, T e)
  3. contains(T[] array, T value)
  4. contains(T[] array, T value)
  5. contains(T[] array, T value)
  6. contains(boolean[] array, boolean valueToFind)
  7. contains(byte[] array, byte valueToFind)
  8. contains(char[] array, char valueToFind)
  9. contains(double[] array, double valueToFind)