A developer shares their successful China Merchants Bank Java backend interview experience, detailing 20 technical questions covering HashMap, ConcurrentHashMap, synchronization, thread pools, Redis cache penetration, MySQL indexing, Spring Boot auto-configuration, Agent memory, RAG, multi-agent orchestration, and more, with answers and preparation tips.
This tutorial explains Red-Black Trees, comparing them with AVL trees, detailing their five properties, three fix operations (recolor, left/right rotations), providing a Python implementation, and covering real-world uses in Java HashMap, Linux kernel, and databases, plus selection guidelines and common pitfalls.
This article explains how Java 8's computeIfAbsent reduces HashMap grouping from three separate lookups (containsKey, put, get) to a single atomic operation, covering lazy evaluation, concurrency safeguards, null handling, nested grouping patterns, and when to prefer computeIfAbsent over Collectors.groupingBy for streaming data.
The article presents a classic interview problem of locating the unique element in an integer array where every other value appears twice, and walks through three Java 17 implementations—brute‑force double loop, HashMap counting, and a bitwise XOR trick—detailing their time and space trade‑offs and practical considerations.
This article walks through ten core Java collection topics—including ArrayList vs LinkedList, HashMap internals across JDK 7 and 8, the put and resize processes, ConcurrentHashMap design, HashSet implementation, fail‑fast vs fail‑safe iterators, and the difference between Collection and Collections—providing the detailed analysis and code examples interviewers expect.
In quant trading systems, hash maps are on the hot path; replacing Rust's default std::collections::HashMap (which uses SipHash) with hashbrown's foldhash can speed up inserts and lookups by up to five times, and the article explains how, why, and when to make the switch.
The article explains how HashMap can enter an infinite loop, lose data, or corrupt entries when accessed concurrently, illustrates the root causes with JDK 1.7 and 1.8 source code, compares alternative thread‑safe maps, and shows how to answer this classic interview question.
The article explains the contract between equals and hashCode in Java, shows what goes wrong when only one is overridden, demonstrates the correct implementation with Objects.equals and Objects.hash, covers IDE/Lombok generation, JPA entity nuances, inheritance pitfalls, records, and common anti‑patterns.
The author argues that understanding frameworks through a debugging mindset and concise demo programs—such as inspecting Redis’s single‑threaded model, Spring’s circular‑dependency resolution, ThreadPoolExecutor’s rejection policy, and HashMap’s resize behavior—provides deeper insight than memorization, and shows how to isolate problems into minimal, testable units.
HashMap is not a simple key‑value store but an array‑based scheduling system that uses a three‑step put process, hash perturbation, bit‑wise indexing, and conditional conversion of long bucket lists into red‑black trees, with resize mechanics that can become performance bottlenecks in high‑concurrency Java applications.
This article dissects a comprehensive set of Barclays Java Spring Boot microservices interview questions, covering HashMap internals, REST method semantics, code implementations, Spring dependency injection, JDBC evolution, JPA/Hibernate usage, SQL injection defenses, microservice architecture essentials, and best‑practice REST API design.
This article explains how to count all boomerang tuples in a set of distinct points by using a hash‑map to store distance frequencies for each anchor point, achieving O(n²) time without costly square‑root calculations and providing Java, C++, and Python implementations.
The article explains why a HashMap lookup can return null even when key objects have identical fields, showing that the default equals and hashCode implementations compare memory addresses, and demonstrates how overriding both methods fixes the issue and avoids real‑world bugs.
The article reviews OPPO’s 2026 campus hiring salaries for backend and algorithm roles, outlines the interview stages, and provides a comprehensive Java guide covering exceptions, checked vs unchecked, reference types, HashMap concurrency issues, ConcurrentHashMap internals, and the differences between synchronized and volatile.
This article combines practical advice for negotiating offers at Tonghuashun with a comprehensive Java interview cheat‑sheet covering method overloading vs overriding, final vs finally, sleep vs wait, HashMap insertion and resizing, reference types, HTTP request structure, status codes, thread‑pool parameters, and garbage‑collection algorithms.
This article explores Java's HashMap internals, detailing its bucket array design, hash processing, collision handling, Java 8 treeification, resizing strategy, load factor and threshold calculations, performance optimization tips, common pitfalls, and when to choose alternative map implementations for high‑concurrency or ordered use cases.
This article explains the mechanisms Java’s HashMap uses to handle hash collisions, covering the initial perturbation function, the transition from linked‑list chaining to red‑black tree conversion, the differences between Java 7 and Java 8 implementations, and the resizing logic that mitigates conflict.
This article explains ClickHouse’s core architecture—including its storage‑compute integration, MPP parallelism, columnar storage, vectorized execution, data pre‑sorting, table engines, sparse and auxiliary indexes, and the two‑stage aggregation pipeline—then walks through the exact GROUP BY execution flow for both local and distributed tables, illustrating each step with diagrams, SQL demos, and code snippets.
Java’s HashMap tackles hash collisions through a combination of perturbation functions, chaining, open addressing, and, since JDK 8, converting long chains into red‑black trees, with detailed explanations of the underlying algorithms, resizing mechanics, threshold choices, and performance trade‑offs for developers and interview candidates.
This article examines Java HashMap traversal techniques, compares keySet, entrySet, iterator and stream approaches, explains why keySet appears to iterate twice by revealing its internal iterator implementation, and presents code examples and decompiled snippets to illustrate the underlying mechanisms.
This article demonstrates how replacing a naïve double‑for‑loop that matches IDs between two large Java lists with a HashMap lookup dramatically reduces execution time, explains the underlying time‑complexity reasons, and provides concrete code examples for both approaches.
This article provides a comprehensive, step‑by‑step analysis of Java's ConcurrentHashMap, covering its evolution from JDK 7’s segment‑lock design to JDK 8’s bucket‑level CAS and synchronized approach, complete with macro diagrams, microscopic source‑code walkthroughs, hash calculations, resizing mechanisms, and practical usage tips.
The article shares a detailed SF interview experience, covering typical Java interview questions such as self‑introduction, challenging projects, learning paths, abstract class vs interface, HashMap vs Hashtable, insertion steps, red‑black and B+ trees, MySQL and Redis indexing choices, large‑table optimization, JVM memory model, and the purpose of the Survivor space.
This article shares a real HSBC interview experience and provides in‑depth explanations of Java HashMap internals, ConcurrentHashMap locking mechanisms, differences between synchronized and ReentrantLock, JVM garbage‑collection nuances, memory‑overflow causes, and practical SQL queries for extracting top scores.
This article walks through a common Java scenario of matching two large lists with nested loops, measures the poor performance, then demonstrates two optimizations—adding a break statement and replacing the inner loop with a HashMap—to dramatically cut execution time.
This article examines the evolution of Java's HashMap from head‑insertion in JDK 1.7 to tail‑insertion in JDK 1.8, explains how the change eliminates circular‑list deadlocks during concurrent resizing, discusses remaining concurrency pitfalls such as red‑black tree conversion, and offers best‑practice solutions like using ConcurrentHashMap and proper initial capacity settings.
The article first highlights Tencent's Q1 2025 financial results and user metrics, then introduces the LeetCode 2013 'Detect Squares' problem, describing its requirements, example, and offering Java, C++, Python, and array‑based solutions along with time and space complexity analysis.
This article explains the internal mechanism of HashMap traversal in Java, detailing how keySet() leads to two iteration steps via an iterator, while entrySet() and Map.forEach() provide a single-pass iteration, and examines the underlying iterator classes and their constructors.
This article explains the various ways to traverse a Java HashMap, compares keySet and entrySet approaches, shows why keySet involves two passes, and demonstrates the underlying iterator implementation with detailed code examples and decompiled snippets.
This article explains Java’s hashCode method, its role in hash-based collections like HashMap and HashSet, how objects are placed in buckets, the necessity of overriding hashCode alongside equals, and how proper implementation improves performance and ensures consistent behavior.
Java’s HashMap stores entries in a hash‑based array where a key’s hash determines the bucket index, resolves collisions with linked lists that become red‑black trees for long chains, resizes when the load factor exceeds 0.75, and requires ConcurrentHashMap for safe multithreaded updates, a core concept often asked in interviews.
This article explains how Java's foreach loop is implemented using iterators, demonstrates the bytecode differences between array and collection traversal, analyzes why modifying a HashMap during foreach can trigger ConcurrentModificationException, and shows the correct way to safely modify collections with an iterator.
A technically proficient developer with seven years of experience keeps getting rejected in first or second interview rounds because he lacks deep understanding of HashMap O(1) mechanics, cannot articulate architecture trade‑offs, and rarely reflects systematically on his projects, as outlined in three key problem areas.
This article explains the fundamentals of hash structures, hash functions, and Java collection implementations such as HashMap, LinkedHashMap, and ConcurrentHashMap, covering their design, collision handling, performance characteristics, and how Redis extends these concepts to a distributed environment.
This article demonstrates how to dramatically speed up Java data‑matching operations that use nested for‑loops by breaking early when a match is found and by converting the inner list into a HashMap for O(1) lookups, showing code examples, performance measurements, and practical tips for backend developers.
An in‑depth comparison of Java’s Hashtable and HashMap covers their thread‑safety mechanisms, null‑key/value policies, inheritance hierarchy, default capacities, resizing strategies, and iterator behavior, highlighting performance trade‑offs and best‑practice alternatives for concurrent applications.
This article explores how mutating the fields of an object used as a HashMap key corrupts its hash code, causing look‑ups to fail, and walks through the underlying source code of put, hash, getNode and related methods to reveal why this happens.
To avoid the O(n × m) cost of naïve nested loops when matching IDs, replace the inner scan with a break after a unique match or, far more efficiently, build a HashMap of the secondary list so each lookup becomes O(1), dropping overall complexity to O(n + m) and cutting execution time from tens of seconds to a few hundred milliseconds.
This article demonstrates how to dramatically speed up Java code that matches items between two large lists by eliminating nested loops, using early‑exit with break and, more effectively, pre‑building a HashMap for O(1) lookups, with concrete timing results and full code examples.
This article demonstrates how replacing a costly nested‑loop search for matching user IDs with a pre‑built HashMap dramatically reduces processing time from tens of seconds to a few seconds, explaining the underlying time‑complexity benefits and providing complete Java code examples.
This article presents five practical Java performance tweaks—pre‑allocating HashMap capacity, using object keys, caching Enum values, replacing String constants with Enums, and upgrading the JDK—backed by JMH benchmarks that show up to 9.5× speed gains.
This article provides a comprehensive analysis of Java's ConcurrentHashMap, covering its underlying data structures, key attributes, core components such as Node, ForwardingNode, TreeBin, and TreeNode, and detailed explanations of the put, get, hash, and resizing algorithms with annotated source code examples.
This article explains the internal mechanism of Java's HashMap traversal, showing that using keySet() triggers two passes—once to create an iterator and once to fetch values—while entrySet() or Map.forEach() can iterate in a single pass, and it walks through the relevant source code to illustrate the process.
In Android, Bundles backed by memory‑efficient ArrayMap use binary search and shrinkable storage, making them far smaller and faster to transmit than HashMaps, whose fixed‑size growth and lack of shrinkage consume more memory; thus Parcelable Bundles are preferred for IPC, while Serializable remains suited only for persistent storage.
This article dissects CPython's dictionary implementation, explaining how a PyDictObject and its PyDictKeysObject are allocated, how method groups map to Python magic methods, and the detailed C logic for inserting, updating, and retrieving key‑value pairs, including __missing__ handling.
This article explains Java's HashMap implementation, covering its bucket array, linked‑list and red‑black tree handling, hash function perturbation, dynamic resizing, and thread‑safety considerations, providing code examples and diagrams for clear understanding.
This article explains the internal architecture of Java's HashMap, covering its array of buckets, linked‑list handling of hash collisions, and the conversion to red‑black trees for high‑collision scenarios, supplemented with code examples and visual diagrams.
The article explains why modifying a HashMap—by removing, adding, or putting entries—while iterating with a Java foreach loop causes a ConcurrentModificationException, demonstrates the underlying bytecode transformation, and shows how to safely perform such operations using an Iterator.
This article demonstrates seven common techniques for iterating over a Java HashMap—including iterator, entrySet, keySet, for‑each loops, lambda expressions, and both single‑threaded and parallel Streams API—providing concise code examples and performance notes for each method.
This article implements seven different HashMap traversal techniques in Java, benchmarks each with JMH, and shows that lambda‑based iteration and entrySet loops are the fastest, followed by Streams, while keySet‑based loops lag behind.
The article shows how using Collectors.toMap can trigger IllegalStateException for duplicate keys and NullPointerException for null values, and demonstrates proper merge functions, Optional handling, and a plain‑for‑loop alternative to safely convert a List of objects into a Map.
Facing massive FullGC alarms due to an oversized in‑memory cache, we leveraged Java’s String.intern() via a custom fastjson deserializer and a rewritten HashMap to deduplicate low‑entropy strings, slashing heap usage by over 1 GB while preserving functionality.
This article explains why iterating a Java HashMap with keySet() involves two passes, examines the underlying iterator implementation, and walks through the relevant source code of HashMap’s KeySet, KeyIterator, and HashIterator classes to clarify the internal traversal mechanism.
This article provides a comprehensive guide to Rust's HashMap, covering its core concepts, creation, insertion, updating, value access, iteration, removal, and advanced entry strategies with clear code examples to help developers use this powerful collection efficiently.
This article surveys Java fundamentals, explaining OOP principles, differences from C++, polymorphism, static/final keywords, abstract classes versus interfaces, generics with type erasure, reflection, exception handling, core data structures, HashMap internals, serialization, key design patterns, and essential language constructs for developers.
This article explains how to construct hierarchical tree data in Java without using recursion by adapting the non‑recursive algorithm from the zTree jQuery plugin, detailing the underlying hash‑map approach, providing full Java code, and discussing performance benefits and limitations.
This article demonstrates how to replace a costly double‑for‑loop that matches two large lists of users with a HashMap lookup, showing performance measurements, the effect of adding a break statement, and detailed Java code examples for backend developers.
This article compiles a set of Java interview questions covering the differences between ArrayList and LinkedList, the internal workings and resizing of HashMap, concurrency primitives like synchronized and ReentrantLock, JVM memory layout, garbage‑collection algorithms, reference types, and Redis persistence and distributed‑lock mechanisms.
This article explains the LeetCode LRU Cache problem, detailing the required class interface, operational constraints, and provides a thorough Java solution using a HashMap combined with a doubly linked list to achieve O(1) time complexity for get and put operations.
This article analyzes a common Java scenario of nested for‑loops over large user and user‑memo lists, demonstrates the performance impact of adding a break statement, and shows how converting the inner list to a HashMap can reduce execution time from tens of seconds to a few seconds.
This article explains Java's HashMap implementation, covering its underlying array‑plus‑linked‑list (and tree) data structure, the hash function with bit‑mixing, collision handling via chaining, and the dynamic resizing mechanism triggered by load factor thresholds.
This article guides developers through a series of Kotlin refactoring steps—replacing when statements with HashMap, introducing payload mechanisms, infix functions, inline registration, and delegated properties—to dramatically improve event‑handling performance, readability, and maintainability while adhering to the single‑responsibility principle.
This article dissects Java's HashMap by first explaining the collection framework's design goals—generality, scalability, performance, interoperability, readability, and thread safety—then walks through the core source code of HashMap (hash, put, resize, get, remove, treeify, etc.), illustrates LRU cache implementation, and finally offers practical usage tips, performance considerations, and version‑specific changes up to JDK 9.
This article walks you through the fundamentals of hash tables, explains bucket arrays and hash functions, discusses collision resolution strategies, and provides a complete Java implementation of a simple HashMap called ThirdHashMap with code, tests, and performance notes.
This article explains the internal mechanics of HashMap traversal in Java, comparing iterator, keySet, entrySet and stream approaches, and reveals why using keySet results in two passes—once to obtain an iterator and once to fetch values—by examining the underlying KeySet, KeyIterator, and HashIterator implementations.
This article explains why iterating a Java HashMap with keySet() results in two traversals, detailing the internal iterator creation, the role of KeyIterator and HashIterator classes, and how the do‑while loop in HashIterator’s constructor locates the first entry, with code examples and bytecode analysis.
This article explains the internal workings of HashMap traversal in Java, showing why using keySet() results in two passes—first converting to an iterator and then fetching values—and details the underlying iterator, KeyIterator, and HashIterator implementations with code examples.
This article explains the internal mechanics of HashMap traversal in Java, showing that keySet() uses an iterator that iterates twice to locate entries, whereas entrySet() (or Map.forEach) iterates only once, and it walks through the relevant source code and decompiled bytecode to illustrate the process.
This article explores four powerful yet understated caching techniques—HashMap with read‑write locks, LinkedHashMap‑based LRU caches, TreeMap for consistent hashing, and ByteBuffer pooling—detailing their implementations in middleware such as RocketMQ, MyBatis, and Cobar to enhance backend performance.
The article examines the role of the volatile modCount field in Java’s HashMap fail‑fast iterator, shows how its declaration changed from JDK5/6 to JDK7/8, and explains why ConcurrentModificationException can occur even in single‑threaded contexts.
This article explains the internal structure of Java’s HashMap across JDK 7 and JDK 8, covering its array‑based storage, linked‑list and red‑black‑tree collision handling, resizing mechanics, load factor choices, power‑of‑two capacity growth, and thread‑safety concerns with practical solutions.
This article explains why specifying an initial capacity for Java's HashMap matters, demonstrates common mistakes, walks through the source‑code calculation of the capacity and resize threshold, and provides guidelines on choosing the correct capacity to avoid unnecessary rehashing and improve performance.
This article explains Java's HashMap initial capacity, how the constructor uses the tableSizeFor method to round the requested size up to the next power of two, and why a power‑of‑two capacity is essential for fast index calculation.
This article explains why specifying an initial capacity for Java's HashMap matters, illustrates common misuse cases, walks through the source code to show how capacity and resizing thresholds are calculated, and provides guidelines for choosing the correct capacity to avoid unnecessary rehashing.
This article examines Ctrip's hotel query service cache, detailing the selection of in‑memory data structures, analyzing Java object and HashMap memory overhead, and demonstrating how bitmap, run‑length, dictionary, and delta encodings dramatically reduce memory usage in real‑world scenarios.
This article explains how Java's HashMap stores key‑value pairs using an array of nodes, how hash functions map keys to array indices, how collisions are handled with linked lists and red‑black trees, and why proper hashCode implementations are crucial for performance.
This article explains how Java's HashMap stores key‑value pairs using an array‑plus‑linked‑list structure, details the hash function, index calculation, collision handling, resizing, and the conditions under which linked lists are replaced by red‑black trees, illustrated with concrete code examples.
The article explains why interviewers probe the implementation details of backend components such as Redis, HashMap, and Memcached, illustrates common interview questions, and shows how mastering the underlying data structures, algorithms, and memory‑allocation mechanisms can improve both interview performance and real‑world problem solving.
This article demonstrates four practical ways to iterate over a Java HashMap—including enhanced for loops with keySet(), iterator-based loops with keySet(), enhanced for loops with entrySet(), and iterator-based loops with entrySet()—and provides a complete example that filters employee objects by salary, complete with full source code.
This article explains why Java’s ArrayList uses a default initial capacity of 10, contrasts it with HashMap’s 16‑element default, and walks through the lazy‑initialization logic and growth algorithm that keep the capacity at ten until the first element is added.
This article examines how Ctrip's hotel query service selects and optimizes in‑memory cache structures—covering Java object layout, HashMap overhead, alternative collections, and various encoding techniques—to achieve high‑performance reads and updates while drastically reducing memory consumption.
This article explores Netty’s IntObjectHashMap, explaining how its use of primitive int keys and open‑addressing linear probing reduces memory overhead and improves performance compared to standard HashMap, while detailing its source‑code evolution, capacity handling, probing strategy, load factor, and deletion compaction.
This article explores how Netty’s IntObjectHashMap improves high‑concurrency ticket‑pricing scenarios by using primitive int keys, open‑addressing linear probing, and careful capacity adjustments, revealing the source‑code evolution, hashIndex optimizations, load‑factor tuning, and deletion compaction that together deliver significant memory and CPU savings.
Iterating a HashMap with a for‑each loop while calling its remove method triggers a ConcurrentModificationException because the loop uses an internal iterator that becomes inconsistent with the map’s modCount, and the article explains the cause, shows decompiled code, and provides correct removal approaches using the iterator or removeIf.
This article explains the internal structure of Java's HashMap and ConcurrentHashMap, covering hash calculation, bucket handling, load factor, resizing, collision resolution with linked lists and red‑black trees, and the differences in thread‑safety and performance between these map implementations.
This article explains Java HashMap's internal structure, including the array‑linked list and red‑black tree design, load factor, collision resolution methods, resizing process, key selection, thread‑safety concerns, and the hash calculation algorithm, providing detailed insights for developers.
This article provides a comprehensive overview of fundamental data structures and algorithms, covering basic concepts, complexity analysis, case studies, and detailed examinations of structures such as HashMap, Bloom filter, SkipList, AVL, Red‑Black, B+Tree, and HashTree, while discussing their advantages, disadvantages, and typical use cases.
This article explains the internal structure of Java's HashMap, how it computes hash codes, resolves collisions using chaining, the impact of load factor and capacity on performance, and provides detailed source code analysis of its key methods such as put, get, resize, and entry handling.
This article explains the JDK 1.8 HashMap resize/re‑hash optimization, showing how the new algorithm splits buckets instead of re‑hashing every entry, and includes the full source code and visual illustrations for single nodes, linked lists, and red‑black trees.
Learn how to implement a Least Recently Used (LRU) cache from scratch using a hash map combined with a doubly linked list in Java, covering the core concepts, node structure, get and put operations, and eviction logic to efficiently manage hot data.
This article compiles a comprehensive set of Tencent interview questions and detailed answers covering HashMap internals, thread safety, red‑black trees, Redis performance, MySQL indexing, TCP reliability, IO multiplexing, RPC, and system bottleneck analysis to help candidates prepare effectively.
This article explains how Java's Float hashCode treats 0.0 and -0.0 as distinct values, causing unexpected behavior when using floating‑point numbers as HashMap keys, and shows how to debug, reproduce, and avoid the issue by using alternative representations.
The article dissects Java’s HashMap put method, explaining how it computes a mixed hash, locates an index in a power‑of‑two table, inserts or replaces nodes in a linked‑list chain that may be converted to a red‑black tree, and triggers resizing when the load‑factor threshold is exceeded.
This article explains the internal structure and algorithms of Java's HashMap and LinkedHashMap, covering node definitions, constructors, hash calculations, collision handling, treeification, resizing mechanics, power‑of‑two bucket sizing, thread‑safety issues, and how LinkedHashMap enables LRU caching.
This article explains the purpose of HashMap's load factor, the trade‑offs between space utilization and collision probability, describes common collision‑resolution techniques such as open addressing, rehashing and chaining, and shows why the default load factor of 0.75 is chosen based on Poisson‑distribution analysis.
This article explains why the pre‑JDK 1.8 HashMap can enter an infinite loop during concurrent resizing, illustrates the problem with detailed step‑by‑step diagrams, and shows how JDK 1.8 redesigns the resize algorithm to prevent the loop.
The article clarifies that the modCount field in java.util.HashMap is used to implement the fail‑fast iterator behavior, explains why the field was volatile in early JDK versions but not in later ones, and shows that ConcurrentModificationException can be thrown even in single‑threaded scenarios when the iterator detects structural changes.
This article provides a comprehensive overview of Java collections, covering the definition, characteristics, differences from arrays, advantages, common collection classes, underlying data structures, fail‑fast mechanism, detailed List, Set, Queue, and Map interfaces, as well as HashMap and ConcurrentHashMap implementations and best practices.
This article explains the internal data structures, hashing mechanisms, resizing behavior, and concurrency strategies of Java's HashMap and ConcurrentHashMap, covering their evolution from JDK 1.7 to 1.8, the use of linked lists, red‑black trees, and lock implementations.
This article explores the challenges of storing billions of mapping records for a DMP in Redis and presents practical solutions such as eviction policies, key bucketing, hash‑map optimization, fragmentation reduction, and specialized memory allocators to achieve millisecond‑level real‑time queries.