First, set set
The set collection stores the elements that are not duplicates.
The following interfaces are included in the collection frame
Collection (ancestor), Set (son SortedSet, grandson Navigableset), List,queue (son deque)
The other is abstract classes (abstract classes are named with abstract) and concrete classes
Interface: A structure similar to a class that contains only constants and abstract methods. Interfaces are very similar to abstract classes in many ways, but their purpose is to indicate the common behavior of multiple objects.
Interfaces are used to define, not to instantiate. C Error
Next look at the set implementation class, Hashset,linkedhashset,treeset
HashSet, a basic implementation of the set interface, is implemented in collection defined methods, such as Add,size,remove,iterator,contains,toarray, etc.
Linkedhashset, which implements an extension of the HashSet class with a list, supports ordering elements within the ruleset, sorted by order of insertion, imposing a different order (ascending or descending), which can be used with TreeSet. For the subject, it is obvious that the output will be [2,1]
TreeSet, supports sorting. This is obviously right.
But when I run, A, B is all right. (A, B are right, of course only for this problem)
Now that there's a sortedlist, revisit the list.
Second, linear table
Linear tables not only store duplicate elements, but also allow the user to specify their storage location.
Interface List (ancestor collection)
Implementing classes ArrayList and LinkedList
Why not SortedList?
Consult API discovery, no it exists!!! It's the "agents" in C # and VB.
(Perhaps I did not find, if someone found in Java exists, please also inform, thank you!!! )
Question Nineth (set set)