Set intersects - Android java.util

Android examples for java.util:Set

Description

Set intersects

Demo Code


//package com.book2s;

import java.util.Set;

public class Main {
    public static boolean intersects(Set<?> a, Set<?> b) {
        if (a.size() < b.size()) {
            for (Object obj : a) {
                if (b.contains(obj)) {
                    return true;
                }/*from  w  w w.  ja va2  s. co m*/
            }
        } else {
            for (Object obj : b) {
                if (a.contains(obj)) {
                    return true;
                }
            }
        }
        return false;
    }
}

Related Tutorials