Java Collection Intersect hasIntersection(Collection c1, Collection c2)

Here you can find the source of hasIntersection(Collection c1, Collection c2)

Description

has Intersection

License

Open Source License

Declaration

public static <T> boolean hasIntersection(Collection<T> c1, Collection<T> c2) 

Method Source Code


//package com.java2s;

import java.util.Collection;

public class Main {

    public static <T> boolean hasIntersection(Collection<T> c1, Collection<T> c2) {
        boolean flag = false;
        for (T t : c2) {
            if (c1.contains(t)) {
                flag = true;/*from   w  w w.j av a2s .c o m*/
                break;
            }
        }
        return flag;
    }

    public static <T> boolean contains(Collection<T> c1, Collection<T> c2) {
        boolean flag = true;
        for (T t : c2) {
            if (!c1.contains(t)) {
                flag = false;
                break;
            }
        }
        return flag;
    }
}

Related

  1. getIntersection( final Collection> collections)
  2. getIntersection(Collection collection1, Collection collection2)
  3. hasIntersection(Collection s1, Collection s2)
  4. hasIntersection(Collection a, Collection b)
  5. hasIntersection(Collection col1, Collection col2)
  6. hasIntersection(final Collection a, final Collection b)
  7. intersect(Collection c1, Collection c2)
  8. intersect(Collection c1, Collection c2)