Here you can find the source of intersectingCollections(Collection extends Object> collection1, Collection extends Object> collection2)
public static boolean intersectingCollections(Collection<? extends Object> collection1, Collection<? extends Object> collection2)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static boolean intersectingCollections(Collection<? extends Object> collection1, Collection<? extends Object> collection2) { if (collection1 == null || collection2 == null) { return false; }/*w w w. j a v a2 s .c o m*/ int size1 = collection1.size(); int size2 = collection2.size(); if (size1 < size2) { for (Object obj : collection1) if (collection2.contains(obj)) { return true; } return false; } for (Object obj : collection2) if (collection1.contains(obj)) { return true; } return false; } }