HashSet
|
TreeSet
|
1The underlying data structure is Hashtable | 1The underlying data structure is balanced tree |
2Heterogeneous objects are allowed | 2 Heterogeneous objects are not allowed by defalut |
3Insertion order is not preserved and it is based on hashcode of the objects | 3 Insertion order is not preserved and all the objects are inserted according to some sorting order. |
4null insertion is possible | 4 As the first element only null insertion is possible and in all other cases we will get NullPointerException (After null insertion other insertion not possible) |
No comments:
Post a Comment