

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
A set is a collection of distinguishable objects, called its members or elements. If an object x is a member of a set S, we write x ∈ S (read "x is a member of S" or, more briefly, "x is in S"). If x is not a member of S, we write x ∉ S. We can describe a set by explicitly listing its members as a list inside braces. For example, we can define a set S to contain precisely the numbers 1, 2, and 3 by writing S = {1, 2, 3}. Since 2 is a member of the set S we can write 2 ∈ S, and since 4 is not a member, we have 4 ∉ S. A set cannot contain the same object more then once, and its elements are not ordered. Two sets A and B are equal, written A = B, if they contain the same elements. For example, {1, 2, 3, 1} = {1, 2, 3} = {3, 2, 1}.
We adopt special notations for frequently encountered sets.
For any set A, we have A ⊆ A. For two sets A and B, we have A = B if and only if A ⊆ B and B ⊆ A. For any three sets A, B, and C, if A ⊆ B and B ⊆ C, then A ⊆ C. For any set A we have ∅ ⊆ A.
Method Summary  
Set 
difference(Set c)
The difference of sets A and B is the set 
Set 
intersection(Set c)
The intersection of sets A and B is the set 
Set 
union(Set c)
The union of sets A and B is the set 
Methods inherited from interface java.util.Set 
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray 
Method Detail 
public Set intersection(Set c)
The intersection of sets A and B is the set
A ∩ B = {x  x ∈ A and x ∈ B}.
Note! Neither set is affected by this operation. To make this set equal to the intersection of itself and c use retainAll(Collection c)
Set.retainAll(Collection c)
public Set union(Set c)
The union of sets A and B is the set
A ∪ B = {x  x ∈ A or x ∈ B}.
Note! Neither set is affected by this operation. TO make this set equal to the union of itself and c use addAll(Collection c)
Set.addAll(Collection c)
public Set difference(Set c)
The difference of sets A and B is the set
A  B = {x  x ∈ A and x ∉ B}.
Note! Neither set is affected by this operation. To make this set equal to the difference of itself and c use removeAll(Collection c)
Set.removeAll(Collection c)


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 