Pages

Topics

Tools

↑↓navigate↵openescclose

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

Latest Java guides

A visual comparison of Java Iterator and Stream traversal approaches showing a cursor versus a pipeline.
Java

Java Iterator vs Stream: Choosing the Right Traversal API

Compare Java's Iterator and Stream APIs to decide which fits your traversal needs, considering state, laziness, performance, checked exceptions, and code clarity.

JavaIteratorStream APIFunctional Programming
A visual comparison of a Java Iterator and a for-each loop, showing a collection being traversed with two distinct paths.
Java

Java Iterator vs For-Each: When to Use Which

Compare the Java Iterator interface with the for-each loop: syntax, element removal, fail-fast behavior, performance, and when to choose each approach.

JavaIteratorFor-Each LoopCollections
A diagram contrasting a Java Set storing unique elements with a Java Map storing key-value pairs.
Java

Java Set vs Map: When to Use Each Collection

Java Set and Map are both collection interfaces, but they solve different problems. Learn how each stores data, common implementations like HashSet and HashMap, and when to use which collection.

Java CollectionsHashSetHashMapSet Interface
Diagram showing aggregation and composition relationships between Java objects with clear ownership and lifecycle markers.
Java

Java Aggregation vs Composition: Ownership and Lifecycle

Understand the practical difference between aggregation and composition in Java, including lifecycle ownership, implementation, and design guidance.

JavaObject-Oriented DesignCompositionAggregation
Two building blocks side by side, one stacked vertically to represent inheritance and one containing smaller parts to represent composition, with a Java logo in the background.
Java

Java Composition vs Inheritance: How to Choose

Compare Java composition and inheritance with concrete examples, tradeoffs, and decision criteria to build maintainable class designs.

compositioninheritanceobject-oriented designJava
Diagram contrasting a static final class constant shared across instances with a final instance field holding a separate value per object.
Java

Java static final vs final: Key Differences

Understand how static final and final differ in Java: where values live, how assignment works, compile-time inlining, memory footprint, and concurrency guarantees.

Javastatic finalfinal keywordJava constants
Diagram showing the difference between runtime method dispatch for instance methods and compile-time resolution for static methods in Java.
Java

Java Overriding vs Method Hiding: Key Differences

Understand the difference between overriding instance methods and hiding static methods in Java, including runtime behavior, compile-time resolution, rules, and examples.

JavaMethod OverridingStatic MethodsPolymorphism
Diagram comparing a Java interface and an abstract class showing state inheritance and multiple implementation contracts
Java

Java Interface vs Abstract Class: How to Choose

A practical guide to choosing between Java interfaces and abstract classes, covering state, constructors, multiple inheritance, default methods, and API evolution.

JavaInterfacesAbstract ClassesOOP Design
Illustration comparing Java's final, finally, and finalize keywords with distinct icons
Java

Java final vs finally vs finalize

java final vs finally vs finalize: Understand the distinct roles of final, finally, and finalize in Java, including syntax, usage, and why finalize is deprecated.

Javafinal keywordfinally blockfinalize method
Illustration comparing equals and compareTo methods in Java with two objects and a sorting arrow
Java

Java equals vs compareTo: Key Differences and When to Use Each

Understand the difference between equals() and compareTo() in Java, including their contracts, consistency requirements, and when to implement each correctly.

JavaequalscompareToComparable