## Javadoc

Sets.cartesianProduct(ImmutableList.of(

returns a set containing six lists:

- ImmutableList.of(1, "A")
- ImmutableList.of(1, "B")
- ImmutableList.of(1, "C")
- ImmutableList.of(2, "A")
- ImmutableList.of(2, "B")
- ImmutableList.of(2, "C")

The result is guaranteed to be in the "traditional", lexicographical order for Cartesian products that you would get from nesting for loops:

for (B b0 : sets.get(0)) }}

Note that if any input set is empty, the Cartesian product will also be empty. If no sets at all are provided (an empty list), the resulting Cartesian product has one element, an empty list (counter-intuitive, but mathematically consistent).

*Performance notes:* while the cartesian product of sets of size
m, n, p is a set of size
m x n x p, its actual memory
consumption is much smaller. When the cartesian set is constructed, the
input sets are merely copied. Only as the resulting set is iterated are the
individual lists created, and these are not retained after iteration.

## Popular methods of Sets

- newHashSetCreates a mutable HashSet instance initially containing the given elements.Note: if elements are non
- newLinkedHashSetCreates a mutable LinkedHashSet instance containing the given elements in order. Note: if mutability
- newTreeSetCreates a mutable, empty TreeSet instance with the given comparator.Note: if mutability is not requi
- unionReturns an unmodifiable view of the union of two sets. The returned set contains all elements that a
- filterReturns the elements of a SortedSet, unfiltered, that satisfy a predicate. The returned set is a liv
- intersectionReturns an unmodifiable view of the intersection of two sets. The returned set contains all elements
- newHashSetWithExpectedSizeReturns a new hash set using the smallest initial table size that can hold expectedSizeelements with
- newIdentityHashSetCreates an empty Set that uses identity to determine equality. It compares object references, instea
- differenceReturns an unmodifiable view of the difference of two sets. The returned set contains all elements t
- equalsImplAn implementation for Set#equals(Object).
- hashCodeImplAn implementation for Set#hashCode().
- immutableEnumSetReturns an immutable set instance containing the given enum elements. Internally, the returned set w

## Popular in Java

- Making http post requests using okhttp
- getSupportFragmentManager (FragmentActivity)
- findViewById (Activity)
- requestLocationUpdates (LocationManager)
- Component (java.awt)A component is an object having a graphical representation that can be displayed on the screen and t
- SocketTimeoutException (java.net)This exception is thrown when a timeout expired on a socket read or accept operation.
- SimpleDateFormat (java.text)Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
- Annotation (javassist.bytecode.annotation)The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
- JButton (javax.swing)
- Runner (org.openjdk.jmh.runner)
- Github Copilot alternatives