In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the characteristics of the Java collection container". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
I. introduction to collection containers
Collection container is the most basic API module in Java development, which is usually used to store dynamically created elements at run time. The basic features are as follows:
Generic features that store objects of any type
Dynamic expansion to store any number of objects
The amount of storage here is constrained by environments such as programs and memory, and as you can see from List's get () method, the scope of index is Integer.MAX_VALUE.
II. API system
Three core interfaces: List, Set inherit Collection, Map independent interface
List and Set system
API:ArrayList,LinkedList, Vector, the core of List system
Core of Set system: API:HashSet, TreeSet, LinkedHashSet
Queue queues API:PriorityQueue, LinkedHashSet
Map system
Core of Map system: API:HashMap, LinkedHashMap, TreeMap, Hashtable
3. Detailed explanation of basic container 1. Core content
Basic usage such as element storage, addition, deletion, modification, search, etc.
Thread safety problems in API method
Container initialization size and dynamic expansion mechanism
Characteristics of underlying data structure
Comparison of containers with the same interface or different interface systems
Basically proficient in using and understanding collection containers, you need to know the following: basic usage of API, thread safety issues; container size and expansion; structural features, arrays, linked lists, hash tables
2. Detailed explanation of API system.
Collection: the root interface of the collection container, defining public methods
List system:
ArrayList
Maintain Object array implementation, features: fast query, slow addition and deletion, non-thread-safe, so high efficiency.
LinkedList
Low-level maintenance linked list data structure implementation, features: slow query, fast additions and deletions, non-thread safety, so high efficiency.
Vector
The bottom maintains the Object array, the implementation is the same as ArrayList, but Vector is thread-safe and inefficient.
Set system:
HashSet
The underlying layer is supported by a hash table, which is characterized by fast access, unique and unordered elements.
LinkedHashSet
The underlying data structure is linked list and hash table, the linked list ensures the order of elements, and the hash table ensures element uniqueness and non-thread safety.
TreeSet
The data structure is a red-black tree, and if the elements have the characteristics of natural order, they are sorted according to the properties of the natural order of the elements, or custom sorting based on the comparator.
Map system:
The implementation class of the Map interface has the characteristics: the stored data is in the way of key-value pairs, the key can not be repeated, the value can be repeated.
HashMap
The underlying hashCode table is used to add elements to the HashMap. Null values and null keys are allowed, and the order of the elements is not guaranteed.
TreeMap
TreeMap: based on the data structure of binary tree, the keys with natural characteristics are sorted and stored: the keys of elements are sorted and stored directly; without natural characteristics, the Comparable interface is implemented and the sorting rules are defined in ComparaTo.
HashTable
Thread-safe, relatively inefficient, null values are not allowed.
3. Container traversal
Process control based on for, foreach and while
Iterable iterator core interface
Lambda expressions: traversing, grouping, querying
This is the end of the content of "what are the characteristics of the Java collection container". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.