the difference between class HashSet and Class Linkedhashset in Java __java

Source: Internet
Author: User
The difference between class hashset<e> and class linkedhashset<e> in Java
Class hashset<e> This class implements the set interface, supported by a hash table (which is actually a hashmap instance). It does not guarantee the iteration order of the set, especially it does not guarantee that the order is immutable. This class allows null elements to be used.
Class linkedhashset<e> a hash table and link list implementation with a set interface that is predictable in iteration order. The difference between this implementation and HashSet is that the latter maintains a doubly linked list running on all entries. This list of links defines the sequence of iterations, that is, the order in which elements are inserted into the set (the insertion order). Note that the insertion order is not affected by elements that are reinserted in set. (If you call S.add (e) immediately after S.contains (e) returns True, Element e is reinserted into set S.) )
This technique is particularly useful if the module uses input to get a set, copy the set, and then return the result of the order that the copy determines. (Customers typically expect content to be returned in the same order as they appear.) )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.