Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set
- - cannot contain duplicates
- TreeSet
- - does not preserve the insertion order of elements but elements are sorted by keys
- - does not allow insertion of Heterogeneous objects (throw ClassCastException at Runtime)
- - excellent choice for storing large amounts of sorted information which are supposed to be accessed quickly because of its faster access and retrieval time
- - operations like printing n elements in sorted order takes O(n) time
- - insertion of null into a TreeSet throws NullPointerException
- HashSet
- - permits the null element
- - does not guarantee the constant order of elements over time (objects are inserted based on their hash code)
- - very important not to set the initial capacity too high (or the load factor too low) if iteration performance is important
- - a hash table stores information by using a mechanism called hashing (the informational content of a key is used to determine a unique value, called its hash code)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement