The reason for the failure of ImmutableCollection.contains(null) is because null is not a valid value in some collections. Immutable collections are designed to be free of null values, and therefore do not support null as a valid value to search for. Additionally, some collections, such as TreeSet and TreeMap, have a natural ordering that cannot include null as it is not comparable to other values. It is generally recommended to avoid using null values in collections to avoid these issues.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-07-11 01:55:13 +0000
Seen: 14 times
Last updated: Jul 11 '23