Here you can find the source of contains(int[] list, int x)
public static int contains(int[] list, int x)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { public static int contains(int[] list, int x) { int pos = -1; if (list.length > 10) pos = Arrays.binarySearch(list, x); else/*from ww w. j av a 2 s .c o m*/ for (int i = 0; i < list.length; i++) if (list[i] == x) pos = i; return pos >= 0 ? pos : -1; } }