Why do I need a collection? What is the difference between a collection and an array?
A: The array is a linear sequence, so it can quickly access the other elements, once the capacity to build it is fixed, and in its life cycle can not be changed.
Collections store their elements as objects, and can dynamically change the size as needed.
--------------------------------------------
What are the collections in Java?
A: List, containing vectors, arraylist,linkedlist
Set, including HashSet, Linkedhashset, TreeSet
Map, including hashmap,hashtable
--------------------------------------------
What is the difference between list and set?
Answer: List is ordered. Element repeatable set is unordered, non-indexed, and no duplicates.
--------------------------------------------
What is the difference between ArrayList and vectors?
A: Vectors are thread-safe, but less efficient.
ArrayList is not thread-safe. But the efficiency is high.
--------------------------------------------
What do I need to be aware of deleting elements?
A: Deleting an element because the element that follows the delete element is automatically moved forward, so it can cause a bug in the program, so you want to remove it from the back.
--------------------------------------------
The elements in list allow repetition, how to go heavy?
A: After iterating through the list collection, assign to another list collection, which is then returned to the list collection by assigning a set set.
--------------------------------------------
What is the difference between the order of TreeSet and list?
A: Order in the list refers to the order in which the elements are placed, while TreeSet refers to the ordering of elements from small to large.
--------------------------------------------
The difference between collection and collentions?
Answer: Collection is a collection interface. The collection interface has many specific implementations in the Java class Library. The meaning of the collection interface is to provide a maximum unified operation for a variety of specific collections.
Collections is a wrapper class that contains a variety of static polymorphic methods related to set operations. This class cannot be instantiated, just like a tool class that serves the Java collection framework.
--------------------------------------------
What's the difference between HashMap and Hashtable?
A: HashMap is thread insecure, high efficiency, key, vaule allow NULL, but key cannot be duplicated.
Hashtable is thread-safe. less efficient. Key, Vaule not allowed to be null
JAVA List Collection