Check if an array contains an int - Android java.lang

Android examples for java.lang:array contain

Description

Check if an array contains an int

Demo Code


//package com.java2s;

public class Main {
    public static boolean contains(int[] arr, int value) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == value) {
                return true;
            }// w w  w .  jav a2 s . c  o m
        }
        return false;
    }
}

Related Tutorials