jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Opposite of a Union Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Opposite of a Union" Watch "Opposite of a Union" New topic

Opposite of a Union

Noah Le

Joined: Aug 12, 2003
Posts: 4
I can't remember the term. Can anyone tell me? It's when you take 2 sets of data and only keep data that's in both sets. also, does Java have a function that performs this action?
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
That's called an "intersection". The Java function, in the Set interface, is retainAll().
Union is addAll(). Set subtraction is removeAll().

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Opposite of a Union
It's not a secret anymore!