- The difference between list and set, map.
List:
1. Duplicate objects can be allowed.
2. You can insert multiple null elements.
3. Is an ordered container that maintains the order in which each element is inserted, and the order in which the output is inserted.
4. Common implementation classes are ArrayList, LinkedList, and vectors. ArrayList is the most popular, providing discretionary access using indexes, while LinkedList is more appropriate for situations where elements are often required to be added or removed from a list.
Set:
1. Duplicate objects are not allowed
2. Unordered containers, you cannot guarantee the order in which each element is stored, TreeSet maintains a sort order by Comparator or comparable.
3. Only one null element is allowed
Some of the most popular implementations of the 4.Set interface are HashSet, Linkedhashset, and TreeSet. The most popular is the HASHMAP implementation-based Hashset;treeset also implements the SortedSet interface, so TreeSet is an ordered container sorted according to its compare () and compareTo () definition
MAP:
1.Map is not a sub-interface or implementation class of collection. Map is an interface.
Each Entry in 2.Map holds two objects, which is a key value, and Map may hold the same value object but the key object must be unique.
3. TreeMap also maintains a sort order by Comparator or comparable.
4. You can have a random null value in Map, but there can be at most one null key. Some of the most popular implementations of the 5.Map interface are HashMap, Linkedhashmap, Hashtable, and TreeMap. (HashMap, TreeMap most commonly used )
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
- Is there a difference between LinkedList and ArrayList?
1.ArrayList is to implement a data structure based on a dynamic array, LinkedList a linked list-based data structure. (linkedlist is a doubly linked list with next and previous)
2. for random access to get and set,ArrayList Feel better than LinkedListbecause linkedlist want to move the pointer.
3. for new and deleted operations add and remove,linedlist comparative advantage, because ArrayList you want to move the data.
java--Set Classic face question