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 9 of 109Java NullPointerException Prevention: Practical Approaches
java nullpointerexception prevention: Learn practical techniques to prevent NullPointerException in Java, including fail-fast validation, Optional, null object pattern...
Java Objects.requireNonNull: Null Checks Without Boilerplate
Learn how to use Java's Objects.requireNonNull to validate null arguments cleanly, with custom messages, constructor usage, and performance considerations.
Non-Null Java Objects: Using requireNonNull, Optional, and @NonNull
Practical guide to enforcing non-null Java object references with Objects.requireNonNull, Optional, and @NonNull annotations to prevent NullPointerException.
Java Objects.isNull: When and How to Use It
Explains Java's Objects.isNull method, when to prefer it over == null, and where Objects.nonNull and Objects.requireNonNull fit in null-safe code.
Java Null Check: Safe Patterns to Avoid NullPointerException
Learn practical Java null-check patterns—from simple if statements to Optional and Objects.requireNonNull—to write safer, more readable code and avoid NullPointerException.
Java Null: Avoiding NullPointerException in Practice
java null: Practical guidance on handling null in Java: early detection, Optional return values, stream filtering, and API design that reduces null exposure.
Java Object Identity vs Equality
Learn the difference between reference identity and logical equality in Java, and how to correctly implement equals() and hashCode().
Java Wrapper Class Equality: == vs equals()
java wrapper class equality: Understand why == fails for wrapper classes, how autoboxing caching affects results, and when to use equals() for reliable comparison.
Java Integer Cache: How It Works and Pitfalls
Learn how Java's Integer cache works, why it affects == comparisons, and how to avoid common pitfalls.
Java Integer == vs equals: What Actually Happens
java integer == vs equals: Why == on Integer objects gives inconsistent results, how the -128 to 127 cache works, and when .equals() is the correct comparison method.