Here you can find the source of containsAny(Collection
public static <T> boolean containsAny(Collection<T> list, Collection<T> values)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 BSI Business Systems Integration AG. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:// w ww. j a v a 2s .c om * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ import java.util.Collection; public class Main { /** * @return true if list contains any (at least 1) of the values */ public static <T> boolean containsAny(Collection<T> list, Collection<T> values) { if (list != null) { for (T o : values) { if (list.contains(o)) { return true; } } } return false; } /** * @return true if list contains any (at least 1) of the values */ public static <T> boolean containsAny(Collection<T> list, T... values) { if (list != null) { for (T o : values) { if (list.contains(o)) { return true; } } } return false; } }