Java guides
Every published Java guide, newest first, with practical examples you can copy into your own project.
3,965 guides across 14 topics
Topics
Popular Java guides
Most readLatest Java guides
Page 12 of 109Defensive Copying in Java Collections: Protect Internal State
Use defensive copying in Java collections to protect internal state, avoid unintended mutation, and decide when copies are safer than unmodifiable views.
Java Defensive Copy: When and How to Use It
Learn how defensive copying in Java protects mutable state, when to apply it, and how to avoid common pitfalls in constructors, getters, collections, arrays, and cloning.
Creating Immutable Classes in Java: A Practical Guide
Learn how to create immutable classes in Java with final fields, defensive copying, records, and builder patterns. Includes common pitfalls.
Java Immutable Object: Implementation and Use Cases
Learn how to design immutable objects in Java, including final fields, defensive copying, and records, and why they improve concurrency safety.
Java Immutable Class: Design and Implementation
Learn how to design immutable classes in Java: final fields, no setters, defensive copying, and why they simplify concurrency and caching.
Java Immutability: Building Safe Immutable Classes
A practical guide to implementing immutable classes in Java: final fields, defensive copying, records, and the tradeoffs to weigh before making every class immutable.
Java HashMap vs ConcurrentHashMap: Choosing the Right Map for Concurrency
java hashmap vs concurrenthashmap: Compare Java HashMap and ConcurrentHashMap: thread safety, performance, null handling, and atomic operations to choose the right map...
Using Java ConcurrentLinkedQueue for Lock-Free Thread-Safe Queues
Learn how to use Java's ConcurrentLinkedQueue for lock-free, thread-safe queue operations, including iteration behavior, performance tradeoffs, and common pitfalls.
Java LinkedBlockingQueue: Producer-Consumer Implementation
Learn how Java's LinkedBlockingQueue works, its capacity behavior, and how to use it in producer-consumer patterns with practical examples.
Java ArrayBlockingQueue: Bounded Queue for Concurrency
Learn how to use Java's ArrayBlockingQueue, a bounded, thread-safe queue for producer-consumer patterns, including capacity, fairness, blocking operations, and performance tradeoffs.