Java Array Search isInArray(final T ch, final T[] a)

Here you can find the source of isInArray(final T ch, final T[] a)

Description

is In Array

License

Apache License

Declaration

public static <T> boolean isInArray(final T ch, final T[] a) 

Method Source Code

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

import java.util.Arrays;

public class Main {
    public static <T> boolean isInArray(final T ch, final T[] a) {
        return Arrays.stream(a).anyMatch(item -> ch.equals(item));
    }/* w w  w. ja v  a2s.  c o m*/

    public static boolean isInArray(final char ch, final char[] a) {
        for (final char c : a) {
            if (c == ch) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. getFoundIdx(char to_find, char[] to_search, boolean do_orderAsc)
  2. indexOf(T[] array, T toSearch)
  3. isIn(char to_find, char[] to_search)
  4. isIn(String name, String[] array)
  5. isIn(String name, String[] array)
  6. isInArray(String needle, String[] haystack)
  7. memchr(boolean[] ary, int start, int len, boolean find)
  8. memchr(char[] haystack, int offset, char needle, int num)
  9. memchr(T[] ptr, T value)