Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.Arrays;

public class Main {
    public static boolean contains(Object[] array, Object value) {
        if (array == null) {
            return false;
        }
        for (Object object : array) {
            if (object == null) {
                if (value == null) {
                    return true;
                }
            } else if (object.equals(value)) {
                return true;
            }
        }
        return false;
    }

    public static boolean contains(int[] array, int value) {
        return Arrays.binarySearch(array, value) >= 0 ? true : false;
    }
}