Detailed explanation of java HashMap source code

Article directory Detailed explanation of java HashMap source code HashMap source code 1 put method process 2 expansion 3 get method Detailed explanation of java HashMap source code Java HashMap is an implementation of the Map interface based on a hash table, which can store a data structure of key-value pairs. The characteristics of HashMap […]

Java collection ConcurrentHashMap What is the difference between how to use each method and HashMap through source code analysis?

Table of Contents Hello friends, today I will analyze the thread-safe hashmap. The main features of ConcurrentHashMap include: ConcurrentHashMap example Let’s take a look at the source code of the size(), containsKey(), and replace() methods. Okay, let’s continue to look at the replace method. The first thing is to check whether a null pointer exception […]

A brief discussion of HashMap and ConcurrentHashMap

As a back-end Java developer, the above-mentioned HashMap and ConcurrentHashMap are essential questions in interviews. Next, let me lead you to take a look. First of all, map is a key value structure, which is often used to store data in memory. hashMap: The data structure is based on **array + linked list**, but the […]

JavaSE22–HashMap

Collection framework_HashMap 1. Overview HashMap is a collection used to store Key-Value key-value pairs. (1) HashMap stores data according to the hashCode value of the key. In most cases, its value can be directly located, so it has fast access speed, but the traversal order is uncertain. (2) In HashMap, only one record with a […]

LinkedHashMap source code analysis

Table of Contents I. Introduction 2. Source code analysis 2.1. Class structure 2.2. Member variables 2.3. Construction method 2.4. accessOrder 2.5. Adding elements 2.6. Get elements 2.7. Delete elements 2.8. Iterators 3. Simple implementation of LRU 1. Foreword HashMap element insertion is unordered. In order to make the traversal order and insertion order consistent, we […]

jdk1.7 -> jdk 1.8 -> jdk 17 HashMap source code analysis

JDK7 (7 U80) is closer to the 8 version. HashMap<String,Integer> map = new HashMap<>(); To create a HashMap object, first call the constructor HashMap(); public HashMap() { this(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR); } Call the HashMap(int initialCapacity, float loadFactor) constructor in the constructor to initialize; where initialCapacity is the initial capacity and loadFactor is the impact factor. public […]

Use Spring Boot, ConcurrentHashMap, Thymeleaf and Bootstrap to implement user caching functions

Original Lutiao Programming Lutiao Programming 2023-10-11 08:00 Published in Hebei included in collection #cache3 #SpringBoot75 This series of courses will cover many key technologies and tools of Spring Boot, including Mybatis-Plus, Redis, Mongodb, MinIO, Kafka, MySQL, Message Queuing (MQ), OAuth2 and other related content. Use Spring Boot, ConcurrentHashMap, Thymeleaf and Bootstrap to implement user caching […]

HashMap source code analysis_jdk1.8 (2)

HashMap source code analysis_jdk1.8 (2) Constructor put method resize expansion method HashMap source code analysis_jdk1.8 (2) Constructor HashMap provides the following constructors: /** * Construct an empty HashMap with the specified initial capacity and load factor. * * @param initialCapacity initial capacity * @param loadFactor load factor * @throws IllegalArgumentException if the initial capacity is […]