What exactly is a 1.java set frame?
The Java Collection framework is the encapsulation of the common data structure in the structure book.
2. What is the architecture of the collection framework?
is to construct data structures that are common in structures through interfaces and classes that implement interfaces.
Nature has the method of adding, deleting, querying, traversing, seeking its length, and placing it empty. In Java is Add (), Remove,get/contain (), iterable (), size (), clear ();
There are 2 main interfaces in the collection framework, one interface is collection, and the other is the map interface.
The collection interface inherits the Iterable interface, which naturally inherits the iterator method, which is mainly used to traverse the data.
Collection interface, there are 3 sub-interfaces, List,set,queue.
The list interface is usually the linear table considered in our data structure.
The linear structures in the data structure have arrays, lists, queues, stacks, and strings.
Arraylist: is an array.
Linklist: That's the linked list.
Vector: It's a dynamic array, stack: It's just stacks.
ArrayList and Vector differences:
Vectors are thread-synchronized, and ArrayList are not synchronous. Higher security vectors.
If it is in a single thread, the use of ArrayList is more efficient and the vector is almost.
Linklist and ArrayList are the differences between arrays and linked lists? Two can be implemented insert, delete and query, a query higher, one insert, delete higher.
Set: is a very simple collection that does not allow elements to be duplicated and does not have a specific order for the elements in the collection.
HashSet: Accessing the elements in a collection using a hashing algorithm is faster.
Set has a sub-interface that is sortedset. This interface provides the ability to sort. The class that implements the SortedSet has treeset.
Map interface: is a collection of keywords and values that is associated with or is a keyword/value pair. Given a keyword, you can get its corresponding value.
HASHMAP: A map based on a hash table, but the class does not guarantee the order.
TREEMAP: Is the implementation of the SortedMap interface based on the red-black tree (the red-black tree is a specific type of two-fork tree, is a self-balancing two-fork tree) sorted in ascending order of keywords.
In addition, the Java.util package also provides two classes for us to use and enrich our use.
Arrays class: traditional static array.
Collections class: Provides operations such as searching, sorting, and thread-complete for various collections.
Comparable interface, which is used to sort the interface. Implement this interface, you can call Arrays.sort (Reference object) or Collections.sort () for automatic sorting.
3.hashCode () and Equals ()?
Hahcode () and equal are generally used in conjunction, and the main solution is to put the objects you create into the set collection, because the set collection is not allowed to be duplicated and encounters duplicate objects (both address and content are equal, hashcode and equal are equal). All the good APIs in Java are implementations of the ToString () method and the hashcode () and Equal methods in object, and the classes that you write must be implemented on their own. So this set set object is exactly how it is implemented, this implementation method and hash table in the chain address method is very similar, different keywords, may also have the same address, and then resolve the conflict, this is the principle of the hash table. If the hashcode code is equal, the equal method is compared, and if the equal method is equal, it is treated as duplicates if not equal, and if the hashcode is unequal, the equal method is not compared.
For more information, please refer to http://blog.csdn.net/afgasdg/article/details/6889383
What is the 4.Comparable interface for?
There is an important method in this interface is the CompareTo () method, which implements the interface method, is equal to 0, is greater than the certificate, less than the negative. Write your own class if you want to have a comparison method, you need to manually implement. This method is used as a comparison between objects and objects.
This article is from the "Jane's Life" blog, please be sure to keep this source http://1464490021.blog.51cto.com/4467028/1922881
Understanding of the Java collection