Java examples for Collection Framework:Array Contain
check if an array contains an int value
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { Object[] myObj = new String[] { "1", "abc", "level", null, "java2s.com", "asdf 123" }; int indexNum = 2; System.out.println(anyEqual(myObj, indexNum)); }//from ww w .j a v a 2 s. c om public static boolean anyEqual(Object[] myObj, int indexNum) { for (int a = 0; a < indexNum; a++) { for (int b = 0; b < indexNum; b++) { if ((a != b) && (myObj[a] == myObj[b])) { return true; } } } return false; } }