Untitled Document

Subscribe here to get updates on new Videos


31. TreeSet part-1?




previous homenext

1. The underlying data structure for TreeSet Is Balanced Tree
2. Duplicate objects are allowed.
3. Insertion order not preserved, but all objects will be inserted according to some sorting order.
4. Heterogeneous objects are not allowed. If we are trying to insert heterogeneous objects then we will get runtime exception saying ClassCastException.
5. Null Insertion is allowed, but only once.

Null Acceptance:

1. For Empty TreeSet as the first element null insertion is possible. But After inserting that null if we are trying to insert any another element we will get NullPointerException.
2. For Non empty TreeSet if we are trying to insert Null then we will get NullPointerException