List collection framework and Set difference

List Set distinguish
List, Set are inherited from both inherited from the Collection interface

List features: element has placed the order, the elements may be repeated

Set Features: no element placed the order, the elements can not be repeated, repeating elements will overwrite

(Note: although no element into the sequence, but the position of the element in the set is determined HashCode the element whose position is fixed in fact, added to the Object Set must define equals () method, additional support for loop list, that is to iterate through the index, you can also use an iterator, but can only be set by an iterative, because he was disorderly, unable to get the desired value using the index.)

 

Set List and contrast:

Set: retrieve elements inefficient, high efficiency of insertion and deletion, insertion and deletion of elements does not cause change in position.

List: and an array of similar, List can dynamically grow, find elements of high efficiency, low insertion and deletion of elements efficiency, because it will lead to other elements of the position change.

Guess you like

Origin www.cnblogs.com/Angledeardayan/p/10986166.html