Code Explainers
Java code explainers
java
public final class BusinessDays { private BusinessDays() { }
Counting business days between two dates in Java
date arithmetic
utility class
streams
Intermediate
7 steps
java
import java.time.Duration; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture;
A safe recurring heartbeat scheduler in Java
concurrency
scheduling
thread-safety
Intermediate
6 steps
java
package com.example.monitoring; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator;
A custom replica health check in Spring
health-check
actuator
monitoring
Intermediate
7 steps
java
@Repository public interface OrderRepository extends JpaRepository<Order, Long> { @QueryHints(@QueryHint(name = HINT_FETCH_SIZE, value = "1000"))
Streaming large result sets in Spring Data JPA
streaming
jpa
memory-management
Advanced
6 steps
java
import java.util.ArrayList; import java.util.Comparator; import java.util.HashSet; import java.util.List;
Three ways to deduplicate a list by key in Java
streams
deduplication
collectors
Intermediate
6 steps
java
public class UnionFind { private final int[] parent; private final int[] rank; private int count;
How union-find with path compression works
disjoint-set
path-compression
union-by-rank
Intermediate
7 steps
java
import java.util.*; public class TopologicalSort {
Topological sort with Kahn's algorithm
graphs
topological-sort
bfs
Intermediate
6 steps
java
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException;
Java try-with-resources and AutoCloseable
try-with-resources
autocloseable
resource-management
Intermediate
6 steps
java
import java.util.Arrays; public class SlidingWindow { // Returns the maximum sum of any contiguous subarray of length k.
The sliding window technique in Java
sliding-window
arrays
algorithms
Intermediate
8 steps
java
import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet;
Breadth-first search on an adjacency-list graph
graph-traversal
bfs
adjacency-list
Intermediate
7 steps
java
public final class Quicksort { private Quicksort() { }
Quicksort with Lomuto partitioning in Java
recursion
divide-and-conquer
in-place
Intermediate
7 steps