public static boolean intersects(Set a,Set b){
  Iterator it;
  Set target;
  if (a.size() <= b.size()) {
    it=a.iterator();
    target=b;
  }
 else {
    it=b.iterator();
    target=a;
  }
  while (it.hasNext()) {
    if (target.contains(it.next()))     return true;
  }
  return false;
}

public static boolean intersects ( Set a , Set b ) { Iterator it ; Set target ; if ( a . size ( ) <= b . size ( ) ) { it = a . iterator ( ) ; target = b ; } else { it = b . iterator ( ) ; target = a ; } while ( it . hasNext ( ) ) { if ( target . contains ( it . next ( ) ) ) return true ; } return false ; }
returns true if the two sets intersect
