Learn Java: Free Java Tutorial in 138 Lessons
Learn Java free: 138 lessons in 20 modules, from first programs to interview questions, with exercises judged on OpenJDK 18 and a certificate.
- Language: Java
- Runtime: OpenJDK 18
- Modules: 20
- Lessons: 138
- Reading time: about 35 hours
- Cost: Free on every plan, with a certificate
The language end to end — types, strings, OOP, generics, collections, streams, memory, concurrency, I/O and modern Java — with exercises judged on a real JDK.
Syllabus
Module 1: Java & the JVM
What Java is, the JDK/JRE/JVM layers, compiling and running, program anatomy, packages, and console I/O.
Module 2: Types & operators
The eight primitives, variables and constants, conversions, integer overflow, floating point, every operator, and the wrapper classes.
- The eight primitive types 14 min
- Variables, constants and var 12 min
- Conversions, promotion and casting 15 min
- Integer arithmetic, overflow and the Math class 14 min
- Floating point — doubles, precision and BigDecimal 15 min
- Operators and precedence 14 min
- Wrapper classes and autoboxing 15 min
- Checkpoint — Types & operators (checkpoint) 25 min
Module 3: Strings
Immutability and the pool, comparison, the String API, StringBuilder, formatting and text blocks, Unicode, and regular expressions.
- Strings are immutable objects 13 min
- Comparing strings — equals, compareTo and hashCode 12 min
- The String API you will actually use 16 min
- StringBuilder — building strings efficiently 12 min
- Formatting output and text blocks 13 min
- Characters, Unicode and encodings 14 min
- Regular expressions in Java 16 min
- Checkpoint — Strings (checkpoint) 25 min
Module 4: Control flow
if/else and guard clauses, every form of switch, the four loops, break/continue/labels, and the loop patterns programs are made of.
Module 5: Methods
Declaring and calling methods, static vs instance, pass-by-value, overload resolution, varargs, recursion, and scope.
- Defining and calling methods 13 min
- Java is pass-by-value — always 14 min
- Overloading and how the compiler picks 14 min
- Varargs — methods that take any number of arguments 10 min
- Recursion — methods that call themselves 16 min
- Scope, lifetime and static context 12 min
- Checkpoint — Methods (checkpoint) 22 min
Module 6: Arrays
Fixed-size typed arrays, 2D and jagged arrays, the Arrays utility class, aliasing versus copying, and the in-place patterns.
Module 7: OOP I — classes & objects
The object model, constructors and initialisation order, static members, access modifiers and immutability, and how to design a class.
Module 8: OOP II — inheritance & polymorphism
extends and super, the rules of overriding, dynamic dispatch and casting, equals/hashCode/toString, abstract classes, and when to compose instead.
- Extending classes — super, constructors and what is inherited 14 min
- Overriding — the rules and the traps 14 min
- Polymorphism, casting and instanceof 14 min
- The Object class — equals, hashCode and toString 16 min
- Abstract classes and the template method 12 min
- When not to inherit — composition, Liskov and final 13 min
- Checkpoint — Inheritance & polymorphism (checkpoint) 24 min
Module 9: Interfaces
Contracts without state, default/static/private methods and the diamond rule, functional interfaces, Comparable and Iterable, and sealed interfaces.
- Interfaces — contracts without implementation 13 min
- Default, static and private interface methods 13 min
- Functional interfaces and the shape of a lambda 13 min
- Comparable, Iterable and designing with interfaces 14 min
- Sealed interfaces — closed sets of types 12 min
- Checkpoint — Interfaces (checkpoint) 22 min
Module 10: Enums & records
Enums as fixed sets of instances with fields and behaviour, EnumSet and EnumMap, and records as transparent immutable data with validation.
Module 11: Nested classes & lambdas
Static nested and inner classes, local and anonymous classes, lambda expressions, method references, and functions as values.
Module 12: Exceptions
The hierarchy, checked versus unchecked, try/catch/finally semantics, try-with-resources, custom exceptions with chaining, and handling practices.
- The exception hierarchy and how to read a stack trace 13 min
- Checked versus unchecked — the rules and the judgement 13 min
- try, catch and finally — the exact semantics 14 min
- try-with-resources and AutoCloseable 12 min
- Custom exceptions and exception chaining 12 min
- Exception handling that survives production 13 min
- Checkpoint — Exceptions (checkpoint) 24 min
Module 13: Generics
Why generics exist, generic classes and methods, bounded types, wildcards and PECS, type erasure and its consequences, and the practical idioms.
Module 14: Collections framework
The framework's map and complexities, lists, sets, maps and HashMap internals, queues and priority queues, sorting with comparators, iteration and fail-fast, immutable collections.
- The collections framework — the map and how to choose 14 min
- Lists — ArrayList, LinkedList and the List API 14 min
- Sets — HashSet, LinkedHashSet and TreeSet 12 min
- Maps — HashMap internals, TreeMap, LinkedHashMap and the modern API 16 min
- Queues, deques and PriorityQueue 12 min
- Sorting, Comparable and Comparator in depth 13 min
- Iterators, fail-fast behaviour and safe modification 11 min
- Immutable collections and the utility toolkit 12 min
- Checkpoint — Collections framework (checkpoint) 26 min
Module 15: Streams
The pipeline model, every intermediate and terminal operation, the collectors — groupingBy, toMap, teeing — Optional as a return type, primitive streams, and parallel execution with its rules.
- Streams — pipelines over data 13 min
- Intermediate operations — map, filter, flatMap and friends 14 min
- Terminal operations — reduce, match, find, count 14 min
- Collectors — toMap, joining, groupingBy, partitioningBy 16 min
- Optional — a return type, not a null replacement 13 min
- Primitive streams — IntStream, LongStream, DoubleStream 12 min
- Parallel streams, ordering and performance 13 min
- Checkpoint — Streams (checkpoint) 30 min
Module 16: Memory and the JVM runtime
Stack frames and the heap, aliasing, object layout, reachability and reference types, generational GC and the collectors, the string pool and Integer cache, class loading and the JIT, and diagnosing leaks.
- Stack and heap — where every value lives 14 min
- Object lifecycle, reachability and reference types 14 min
- Garbage collection — generations, pauses and the collectors 15 min
- The string pool, interning and the Integer cache 13 min
- Class loading, initialisation order and the JIT 15 min
- Diagnosing memory problems — leaks, dumps and bounded caches 14 min
- Checkpoint — Memory and the JVM runtime (checkpoint) 30 min
Module 17: Concurrency
Threads and interruption, races and synchronized, the memory model and volatile, executors and Futures, locks, atomics and ConcurrentHashMap, CompletableFuture, latches, barriers and blocking queues.
- Threads and Runnables — starting, joining, interrupting 14 min
- Shared state, races and synchronized 15 min
- Visibility, volatile and the Java Memory Model 15 min
- Executors, thread pools and Futures 14 min
- Locks, atomics and the concurrent collections 15 min
- CompletableFuture and the coordination tools 15 min
- Checkpoint — Concurrency (checkpoint) 30 min
Module 18: I/O, files and time
Byte and character streams with charsets, buffering and the fast-I/O template, Path and Files, serialization and CSV done right, and java.time — dates, zones, durations and formatting.
- Bytes and characters — streams, readers and encodings 14 min
- Buffering and fast I/O — the template that passes time limits 13 min
- Files and paths — java.nio.file 14 min
- Serialization, CSV and the formats you actually use 14 min
- java.time — dates, times, zones and durations 15 min
- Checkpoint — I/O, files and time (checkpoint) 28 min
Module 19: Modern Java
The release train and LTS milestones, var and inference, pattern matching for instanceof, switch and records, the library additions from 9 to 21, virtual threads and structured concurrency, modules and the toolchain.
- The release train — what changed from Java 9 to 21 13 min
- var and type inference — what the compiler already knows 12 min
- Pattern matching — instanceof, switch and record patterns 15 min
- The API additions worth knowing, 9 to 21 14 min
- Virtual threads and structured concurrency 13 min
- Modules, jshell and the modern toolchain 13 min
- Checkpoint — Modern Java (checkpoint) 26 min
Module 20: Interview idioms
The fast template and complexity budget, the equals/hashCode/Comparable contracts, the thirty pitfalls, the collections idiom sheet, clean solutions under pressure, and the Java theory drill.
- The interview template — input, output, limits 12 min
- equals, hashCode and Comparable — the contracts that make collections work 14 min
- The pitfalls that fail interviews 14 min
- The collections idiom sheet 15 min
- Writing clean solutions under time pressure 12 min
- The Java theory drill — thirty questions, thirty answers 16 min
- Final checkpoint — Interview idioms (checkpoint) 32 min