Using null to represent an empty set is a bad idea . A null does not behave like a Set , because (obviously) all attempts to perform an operation on it will throw a NullPointerException . This means that if you use null to indicate an empty set, you will be clogged with tests for null ... and if you skip one, you will get an error.
The solution is to use Collections.emptySet () if you want an immutable empty set, or create an instance of the corresponding Set class if you want the modified set to start from empty.
Stephen c
source share