Java examples for Collection Framework:Array Contain
Check if an int array contains an int value
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int[] array = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; int key = 2; System.out.println(contains(array, key)); }/*www.j a va 2 s .c o m*/ public static boolean contains(int[] array, int key) { for (int i = 0; i < array.length; i++) { if (array[i] == key) { return true; } } return false; } }