Java

61 articles in this topic

Functional Interfaces in Java: SAM Rules, Lambdas and Runnable Examples

Build functional interfaces from zero, replace an anonymous class with a lambda, select standard interfaces by shape, and avoid common compiler traps.

Updated 10 Nov 20265 min readJava

TreeMap and SortedMap in Java: Ordering, Range Views and Worked Examples

Learn how Java's TreeMap orders keys, answers floor and ceiling queries, exposes live range views, and handles comparator collisions through worked examples.

Updated 9 Nov 20266 min readJava

HashSet and TreeSet in Java: Runnable Examples and Key Differences

Learn how Java sets handle duplicates, ordering, navigation and custom objects through deterministic examples you can run and modify.

Updated 8 Nov 20265 min readJava

Java Garbage Collection Tutorial: Reachability, Leaks and Runnable Examples

Trace three connected objects, find exactly when each becomes eligible for collection, and repair a cache that keeps byte arrays reachable.

Updated 7 Nov 20266 min readJava

Java Memory Model Tutorial: Happens-Before, volatile and Safe Publication

Learn the Java Memory Model through exact start/join, volatile, synchronized, final-field and AtomicInteger examples, with clear happens-before guarantees.

Updated 6 Nov 20266 min readJava

Java Exception Handling Tutorial with Runnable Examples

Learn how Java moves control through try, catch, and finally, then build checked custom exceptions and safer file handling with runnable code.

Updated 5 Nov 20266 min readJava

Annotations in Java Tutorial: Custom Metadata, Retention and Reflection Examples

Create a custom Java annotation from zero, inspect its values through reflection, and learn how retention, targets and defaults control the result.

Updated 3 Nov 20265 min readJava

Collections Framework in Java: Interfaces, Implementations, and Examples

Learn how List, Set, Map, and Deque fit together, then choose implementations confidently through one consistent Java example.

Updated 2 Nov 20265 min readJava

JDBC in Java Tutorial: Connections, Queries and Transactions with Examples

Build and run one Java 17 program that creates an H2 table, inserts three products, filters them safely, then rolls back and commits two stock updates.

Updated 1 Nov 20266 min readJava

Inheritance in Java: Learn extends, super, and Overriding with Runnable Examples

Follow one runnable Vehicle and ElectricCar program to see inherited methods, constructor order, super calls, runtime dispatch, common errors, and practice tasks.

Updated 31 Oct 20266 min readJava

Encapsulation in Java: Build Safer Classes with Runnable Examples

Learn how a Java class can protect valid state through private fields, behaviour methods, validation before mutation, and defensive collection copies.

Updated 30 Oct 20265 min readJava

Operators in Java: Types, Precedence and Runnable Examples

Learn how Java evaluates arithmetic, assignment, unary, logical, bitwise and ternary operators through code and step-by-step output traces.

Updated 28 Oct 20266 min readJava