Java examples for java.util:List Contain
Check if an Integer is Contained in List by binary search
//package com.book2s; import java.util.*; public class Main { public static boolean isContain(List<Integer> list, Integer i) { if (isCollectionEmpty(list) || i == null) { return false; }//w w w . j av a 2s . c om return Collections.binarySearch(list, i) >= 0; } public static <T> boolean isCollectionEmpty(Collection<T> collection) { return collection == null || collection.isEmpty(); } }