Expressions in mathematics are expressed by using generic methods and set: The orthogonal complement of the collection, which copies the first parameter set in the following three methods, and does not directly modify the set in the parameter.
Package Set;import Java.util.hashset;import Java.util.set;public class Sets {public static <T> set<t> Intersection (set<t> s1, set<t> s2) {set<t> result = new hashset<t> (s1); Result.retainall (S2); return result;} Public Static <T> set<t> Union (set<t> S1, set<t> s2) {set<t> result = new hashset<t& gt; (s1); Result.addall (S2); return result;} Subtract subset from Supersetpublic static <T> set<t> difference (set<t> superset, set<t> subset) {set<t> result = new hashset<t> (superset); Result.addall (subset); return result;} Reflexive--everything not in their intersectionpublic static <T> set<t> complement (set<t>s1,set <T> S2) {Return Difference (Union (S1,S2), intersection (S1,S2));}}
Java Collection orthogonal complement