1 response

  1. pushpendra tyagi
    February 27, 2020

    HashSet exhibits constant-time performance for the basic operations (add, remove, contains and size).HashSet does not guarantee that the order of elements will remain constant over time.
    TreeSet guarantees log(n) time cost for the basic operations (add, remove and contains). TreeSets guarantee that elements of the set will be sorted in ascending, natural, or the one specified by you via its constructor. (by implementing Comparable interface).
    Overall great Blog on this Java topic.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top
mobile desktop