How can i tell if two Collections contain the same elements or have no elements in common?

Brandon Rohlfs

Two methods are needed in this case.

boolean containsAll(Collection<?> c)
boolean disjoint(Collection<?>c1 Collection<?>c2)
Since containsAll(Collection<?> c) is defined within the Collection interface all concrete implementations will be able to use this method. disjoint(Collection<?>c1 Collection<?>c2) is defined within the Collections class.

Using both of these methods is pretty straightforward. containsAll(Collection<?> c) is an instance method so naturally it must be invoked on an object. disjoint(Collection<?>c1 Collection<?>c2) is defined as Static within the Collections class so all that is needed is to invoke it using the class name ie Collections.disjoint(Collection<?>c1 Collection<?>c2)