The last set operation we will cover is the subset. An example of the mathematical concept of subset is that A is a subset of (or is included in) B, and this is denoted by:
The set is defined as:
This means that for every x (element) that exists in A, it also needs to exist in B. The following diagram exemplifies when A is a subset of B:
Now, let's create the isSubsetOf method in our Set class using the following code:
isSubsetOf(otherSet) ...