CHAPTER 30: Set collection

Set Interface Overview

  Set a collection of the biggest feature is not allowed to save repeating element, which is also a sub-interface Collection.

  Set in the previous set of definitions JDK1.9 collection Collection no difference, Set to continue to use the methods of the Collection interface provided by the operation, but after JDK1.9, Set List collections also want to expand the collection as a number of static methods, Set set defined as follows:

  Note that the Set List collection is not as a collection of a number of expansion as new methods can not be used to provide collection List of get () method, that is, it can not be achieved to obtain the specified index data, Set inheritance as follows:

  After from JDK1.9, Set collection also offers a similar collection as among the List of () static method. But with of () will throw an exception when the method was found to Set collection holds duplicate elements, because it can not save duplicate elements.

  Set General Applicability set is necessarily rely subclass is instantiated, it is among the Set interface has two subclasses: HashSet, TreeSet.

HashSet subclass

 

TreeSet subclass

Analysis subclass sort operation TreeSet

Eliminate duplicate element analysis

Guess you like

Origin www.cnblogs.com/djlindex/p/11346248.html