Java starts from scratch, and the basics of learning notes & lt; set & gt; (16)

Source: Internet
Author: User

Set: add multiple elements to a set object. The corresponding set object can be used to store multiple elements. Sub-interfaces of the Collection interface: Set interface and List interface. Map is not a sub-interface of the Collection interface. The Collection interface organizes a group of objects in the form of Collection elements, and implements different organization methods in the sub-interfaces. To create a Collection interface, you need to use its sub-interfaces to implement the following classes: ArrayList class, sorted list class, Vector class, And Stack class; two-way linked list storage structure. The rule of storage elements is first-in-first-out, and then output. Vector can also be used to create a variable-length array object. It also saves the method for operating the array. Stack class storage data comes first and then comes first. If we need to create an object of the Collection interface, we can assign the object of the implementation class of the interface to the reference of the interface. Collection col = new ArrayList (); Set interface: a sub-interface of the Collection interface. Data stored in the Set is unnecessary and not repeated, if the same data is stored in the same operation, the stored data replaces the existing data with the Implementation class of the Set interface: TreeSet class (ordered) and HashSet class (unordered) create a Set <generic> set = new HashSet <generic> (); List interface: a sub-interface of the Collection interface. Data stored in the List set can be sequential and repeated. A List set can not store null strings (print the length of the List) to create a List set Object List <generic> list = new ArrayList <> (); Map interface: it is not a sub-interface of the Collection interface, its implementation class HashMap, TreeMap, HashTable, WeakHashMapMap set to store data in the form of K-V, the key values in the Map set can not be repeated, the value can be repeated. Create a Map set object Map <generic> map = new HashMap <generic> (); Map <generic> map1 = new HashMap <generic> (); what is the difference between HashMap and HashTable? 2. HashMap running a null value HashTable does not allow a Null value. 2. The HashMap method does not synchronize the HashTable method. 2. The containValue method HashTable in HashMap has a contain method 2. The HashMap thread is insecure. HashTable thread security 2. HashMap uses iterative output HashTable and enumeration output

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.