Here you can find the source of intersectComparable(Set
public static <T extends Comparable<T>> Set<T> intersectComparable(Set<T> left, Set<T> right)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <T extends Comparable<T>> Set<T> intersectComparable(Set<T> left, Set<T> right) { List<T> mid = new LinkedList<T>(left); mid.removeAll(right);/*w w w . j a va2 s .c om*/ Set<T> result = new TreeSet<T>(left); result.removeAll(mid); return result; } }