Java Array Has inArray(int[] arr, int search)

Here you can find the source of inArray(int[] arr, int search)

Description

in Array

License

Open Source License

Declaration

public static boolean inArray(int[] arr, int search) 

Method Source Code

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

public class Main {

    public static boolean inArray(int[] arr, int search) {
        if (arr != null) {
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] == search) {
                    return true;
                }//  ww  w  .  j  a  v a  2s.  c o  m
            }
        }
        return false;
    }

    public static boolean inArray(int[] arr, int[] search) {
        if (search != null) {
            for (int i = 0; i < search.length; i++) {
                if (!inArray(arr, search[i])) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }

    public static boolean inArray(char[] arr, char search) {
        if (arr != null) {
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] == search) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean inArray(char[] arr, char[] search) {
        if (search != null) {
            for (int i = 0; i < search.length; i++) {
                if (!inArray(arr, search[i])) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }

    public static boolean inArray(byte[] arr, byte search) {
        if (arr != null) {
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] == search) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean inArray(byte[] arr, byte[] search) {
        if (search != null) {
            for (int i = 0; i < search.length; i++) {
                if (!inArray(arr, search[i])) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }

    public static boolean inArray(Object[] arr, Object search) {
        if (arr != null && search != null) {
            for (int i = 0; i < arr.length; i++) {
                if (search.equals(arr[i])) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean inArray(Object[] arr, Object[] search) {
        if (search != null) {
            for (int i = 0; i < search.length; i++) {
                if (!inArray(arr, search[i])) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }

    public static boolean inArray(String[] arr, String search) {
        if (arr != null && search != null) {
            for (int i = 0; i < arr.length; i++) {
                if (search.equals(arr[i])) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean inArray(String[] arr, String[] search) {
        if (search != null) {
            for (int i = 0; i < search.length; i++) {
                if (!inArray(arr, search[i])) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }
}

Related

  1. inArray(byte needle, byte[] haystack)
  2. inArray(byte needle, byte[] haystack)
  3. inArray(char[] array, char c)
  4. inArray(final String s, final String[] array)
  5. inArray(final T[] array, final U search)
  6. inArray(int[] array, int needle)
  7. inArray(Object[] ps, Object p)
  8. inArray(String arg, String[] array)
  9. inArray(String needle, String... haystack)