Here you can find the source of hasIntersection(Set
Parameter | Description |
---|---|
set | A given set. |
list | A given list. |
T | Type of the objects in set or list. |
public static <T> boolean hasIntersection(Set<T> set, List<T> list)
//package com.java2s; /*/*from www . j av a 2s .co m*/ * This file is released under terms of BSD license * See LICENSE file for more information */ import java.util.*; public class Main { /** * Check if there is an intersection between the set and the list. * * @param set A given set. * @param list A given list. * @param <T> Type of the objects in set or list. * @return True if there is an intersection. False otherwise. */ public static <T> boolean hasIntersection(Set<T> set, List<T> list) { for (T n : set) { if (list.contains(n)) { return true; } } return false; } }