Java
(20 posts)Core Java fundamentals, algorithms, and problem-solving patterns. Each post includes runnable code with test cases so you can try it yourself.
All Posts
Java 25 — String Templates & Flexible Constructor Bodies
Java 25 finalizes string templates with the STR processor and flexible constructor bodies — two features that simplify everyday Java code.
Java 25 — Primitive Types in Patterns & instanceof
Java 25 finalizes primitive type patterns — use int, long, double, and boolean in instanceof checks and switch expressions. Practical examples and migration tips.
Java 21 — Scoped Values — The ThreadLocal Replacement
Understand Java's Scoped Values — why they replace ThreadLocal, how they work with virtual threads, and practical patterns for request-scoped data.
Java 21 — Structured Concurrency
Understand Java's Structured Concurrency API — StructuredTaskScope, ShutdownOnFailure, ShutdownOnSuccess, and how it prevents thread leaks in concurrent code.
Java 21 — Sequenced Collections — Finally, a First/Last API
Java 21's Sequenced Collections add getFirst(), getLast(), and reversed() to List, Set, and Map — the API Java has been missing for 25 years.
Java 21 — Record Patterns & Sealed Classes in Practice
Use Java 21's record patterns and sealed classes together — destructuring records in switch, nested patterns, and building type-safe domain models.
Migrating from Java 17 to 21 — What Breaks, What Improves
A practical migration guide from Java 17 to 21 — breaking changes, deprecated removals, new features to adopt, and step-by-step upgrade process.
Java 21 — Pattern Matching for switch (Exhaustive & Guarded)
Master Java 21's pattern matching for switch — type patterns, guarded patterns, null handling, exhaustiveness, and practical examples for cleaner code.
Java 21 — Virtual Threads Explained with Real Examples
Understand Java virtual threads — how they work, when to use them, migration from thread pools, and real-world performance comparisons with platform threads.
Java 25 — What's New in the Next LTS
A practical overview of Java 25 LTS — the features that matter, what's finalized from preview, and what you need to know before upgrading from Java 21.
JSON Parsing in Java — Which Library Should You Use?
A side-by-side comparison of org.json, Gson, Moshi, and Jackson for JSON parsing in Java — with recommendations for Android, backend, and new projects.
JSON Parsing in Java — Parsing with Jackson
Parse a real-world JSON response using Jackson in Java 21. ObjectMapper, annotations, and the JavaTimeModule for dates.
JSON Parsing in Java — Parsing with Moshi
Parse a real-world JSON response using Moshi in Java 21. Clean annotations, custom adapters, and built-in null safety.
JSON Parsing in Java — Parsing with Gson
Parse a real-world JSON response using Gson in Java 21. Automatic mapping, annotations, and custom adapters — the easy way.
JSON Parsing in Java — Manual Parsing with org.json
Parse a complex, real-world JSON response manually using org.json in Java 21. Every getString, every null check, every nested loop — the hard way.
Rearrange positive and negative numbers in an array — Java
Partition an array so all negative numbers appear on the left and positive numbers on the right, in-place with only one extra variable.
Convert JSON to comma-separated key=value pairs — Java
Recursively flatten a nested JSON object into a compact comma-separated key=value string in Java.
“Check if a string has balanced brackets — Java”
“Use a stack to check if a string has balanced opening and closing brackets. Handles parentheses, square brackets, and curly braces.”
== vs equals() in Java — What's the difference?
Understanding the difference between the == operator and equals() method in Java, and why using the wrong one leads to subtle bugs.
String Concatenation in Java — concat() vs + vs StringBuilder
Understanding the real differences between concat(), the + operator, and StringBuilder in Java — what actually matters and what doesn't.