Question: why null value is not allowed in treeset?
Answer: Why TreeSet Does not allow null values in Java? ... The reason is, if you look at the internal implementation of the TreeSet, it uses natural ordering, that means TreeSet uses Comparable interface by default to sort its value by comparing other value.