Assuming that you want to implement set theory concepts such as element
, set
, collection
and relation
in Java: How would you represent the empty set ∅
?
Do I mislead myself, if I think of the NULL
concept as it is used by the three-valued logic of databases?
Empty Set (Null Set) A set that does not contain any element is called an empty set or a null set. An empty set is denoted using the symbol '∅'. It is read as 'phi'.
A second set could be defined as having only one element by letting that element be the empty set itself (symbolized by {Ø}), a set with two elements by letting them be the two… The empty (or void, or null) set, symbolized by {} or Ø, contains no elements at all.
By the definition of topology (https://en.wikipedia.org/wiki/Topology#Mathematical_definition) the empty set is always open and its complement (i.e. the whole other set) is always closed. Therefore is the emtpy set open and closed in every topology.
Use Collections.emptySet():
Returns the empty set (immutable). This set is serializable. Unlike the like-named field, this method is parameterized. This example illustrates the type-safe way to obtain an empty set:
Set<String> s = Collections.emptySet();
Implementation note: Implementations of this method need not create a separate Set object for each call. Using this method is likely to have comparable cost to using the like-named field. (Unlike this method, the field does not provide type safety.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With