Java Fundamentals Roadmap
Follow Java from your first runnable program through objects, collections, exceptions, and core libraries. Build an artifact at every stage.
Follow Java from your first runnable program through objects, collections, exceptions, and core libraries. Build an artifact at every stage.
Java Fundamentals Roadmap
Java is used for backend services, Android apps, and other software that runs on the JVM. This roadmap starts with a small program, then moves through control flow, objects, collections, exceptions, and core libraries.
Each stage has an artifact you can build before moving on. You can stop at any checkpoint and still have a working program to keep or improve.
Before You Start
- Basic computer literacy (installing software, navigating file systems, using the command line)
- No prior programming experience required β we start from absolute zero
- A machine with at least 8GB RAM and a modern operating system (Windows/macOS/Linux)
First Exercise: Compile and Run a Class
Save this as Hello.java:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
From the same directory, compile and run it:
javac Hello.java
java Hello
The program should print Hello, Java!. Change the message, compile again, and run it once more. This is the first checkpoint: you can edit a source file and run it with the JDK.
The Roadmap
π Getting Started with Java
π€ Variables and Data Types
β‘ Operators and Control Flow
π§ Methods and Method References
ποΈ Object-Oriented Programming
πΎ Arrays and Collections
π Exception Handling
π Core Java Libraries
βοΈ Generics and Type System
π― Next Steps
Timeline & Milestones
π Estimated Timeline
π Capstone Track
- Design classes with encapsulation and inheritance
- Store tasks in ArrayList/HashMap
- Handle exceptions for invalid input and missing files
- Serialize tasks to disk using java.io or java.nio.file
- Write generic classes with bounded type parameters
- Apply wildcards in utility methods
- Demonstrate type erasure and bridge methods conceptually
- Filter, map, and collect with streams
- Use java.time for date manipulation
- Format reports with java.text.Formatting
- Optional: implement a simple lambda-based plugin system
Milestone Markers
Use these checkpoints to decide when to move on. The artifact matters more than finishing a stage on a particular week.
| Stage | Artifact to keep | Next step |
|---|---|---|
| Getting started | A changed Hello.java that you compiled and ran from the command line. |
Declare variables and compare primitive and reference types. |
| Variables and data types | A small unit converter with sample inputs and outputs. | Add branches and loops to validate input and handle several conversions. |
| Operators and control flow | A menu-driven calculator that handles more than one operation. | Move each operation into a method with a clear input and return value. |
| Methods and lambdas | A small utility program split into methods, with one lambda example you can explain. | Model the programβs data with classes and constructors. |
| Object-oriented programming | A Book class and a LibraryCatalog that protects its internal state. |
Store and search multiple books with arrays and collections. |
| Arrays and collections | A grade tracker that stores entries and calculates summaries. | Add input validation and deliberate error handling. |
| Exception handling | A command-line program that reports invalid input without exposing a stack trace to the user. | Use core libraries and generics to process structured data. |
| Core libraries and generics | A typed report generator that groups dated records and writes a summary. | Build the capstone by combining these pieces into one application. |
| Capstone | A task manager with file persistence, a README, and a few tests for its core behavior. | Pick a next route below: testing, Spring Boot and microservices, or JVM diagnostics. |
Core Topics: When to Use / When Not to Use
Arrays vs ArrayList β When to Use vs When Not to Use
| When to Use | When NOT to Use |
|---|---|
| Performance-critical code where you know the exact size upfront and need minimal indirection | You need to frequently add or remove elements β ArrayList handles resizing automatically |
| Multidimensional data such as matrices or game grids (2D arrays are natural) | You need to store non-primitive objects directly β use ArrayList of objects instead |
| Low-level interop with APIs that expect primitive arrays (e.g., some JVM intrinsics) | You need type-safe iteration β ArrayListβs enhanced for-loop is clearer |
Trade-off Summary: Arrays give you predictable O(1) indexed access with no object overhead for primitives, but they are fixed-size and provide no built-in safety. ArrayList trades a small constant-factor overhead for dynamic resizing and richer API β use arrays when size is known and fixed; use ArrayList when collection size changes frequently or you want convenience methods like add, remove, and contains.
HashMap vs TreeMap vs HashSet β When to Use vs When Not to Use
| When to Use | When NOT to Use |
|---|---|
| HashMap when you need O(1) average-case key-value lookups and donβt care about ordering | You need keys sorted in natural or custom order β use TreeMap instead |
| HashSet when you only need to track unique elements and check membership | You need to maintain insertion order β use LinkedHashSet |
| TreeMap when you need sorted keys, range queries (subMap, headMap, tailMap), or a NavigableMap | You need strictly O(1) lookups β TreeMap is O(log n) due to Red-Black tree underlying structure |
Trade-off Summary: HashMap and HashSet offer constant-time performance for most operations but provide no ordering guarantees and are sensitive to poor hash functions. TreeMap/TreeSet give you sorted iteration and range queries at O(log n) cost β choose based on whether you need ordering or maximum speed.
Checked vs Unchecked Exceptions β When to Use vs When Not to Use
| When to Use | When NOT to Use |
|---|---|
| Unchecked exceptions (RuntimeException subclasses) for programming errors that are typically unrecoverable β NullPointerException, IllegalArgumentException | Checked exceptions for errors that a caller can reasonably be expected to handle β IOException, SQLException |
| Checked exceptions at API boundaries where the caller must acknowledge the failure possibility (file not found, network timeout) | Internal library code that cannot meaningfully recover β donβt wrap every RuntimeException in a checked exception |
Trade-off Summary: Checked exceptions enforce explicit error handling at compile time, making APIs more transparent about failure modes, but they pollute method signatures and force callers to handle or declare them. Unchecked exceptions keep code clean but require discipline to handle at appropriate boundaries. A common anti-pattern is using checked exceptions for routine business logic validation instead of using unchecked exceptions for truly unexpected conditions.
Generics: Bounded Types vs Wildcards β When to Use vs When Not to Use
| When to Use | When NOT to Use |
|---|---|
Bounded type parameters (<T extends Comparable>) when you need to call methods specific to a type hierarchy |
Unbounded wildcards (<?>) when you only need to read from a collection, not write to it |
Lower-bounded wildcards (<? super T>) when writing to a collection β e.g., a method that populates a list |
Upper-bounded wildcards (<? extends T>) when you need to both read and write to a collection |
Concrete type parameters (<String>) when you need the exact type back from a generic method |
Raw types (List without <>) β they bypass generics entirely and produce unchecked warnings |
Trade-off Summary: Bounded type parameters give you the most flexibility β you can read and write using the bound type. Upper-bounded wildcards let you read as the bound type but not write (producers). Lower-bounded wildcards let you write as the bound type but constrain what you can read (consumers). Using the wrong wildcard direction is the classic producer/consumer confusion β PECS (Producer Extends, Consumer Super) summarizes the rule.
Composition over Inheritance β When to Use vs When Not to Use
| When to Use | When NOT to Use |
|---|---|
| You want runtime behavior changes without subclassing β inject dependencies via constructor | You genuinely need the βis-aβ relationship β a subclass truly is a specialization of its parent (e.g., ArrayList is-a List) |
| You want to avoid fragile base class problems where changes to a parent break subclasses | You need to override specific methods and still benefit from polymorphic dispatch |
| You want loose coupling and easier unit testing β mock the composed component | Performance-critical code where virtual method dispatch overhead matters (rare in practice) |
Trade-off Summary: Inheritance creates tight coupling between parent and child classes β the child depends on implementation details of the parent, making systems brittle as hierarchies grow. Composition favors loose coupling, easier testing, and runtime flexibility, but it requires more explicit delegation code. Default to composition; reach for inheritance only when βis-aβ and polymorphic behavior are genuinely what you need.
Resources
Official Documentation
- Oracle Java Tutorials β A getting-started guide from Oracle
- Java Language Specification β The formal specification for Java language features
Related Java Guides
- Java collections utility guide β Compare common collection operations and their behavior
- JUnit 5 and Jupiter β Add tests around the programs you build
- JVM architecture overview β Continue into class loading and runtime details
Books
- Head First Java by Kathy Sierra and Bert Bates β Visually-rich introduction for absolute beginners
- Effective Java by Joshua Bloch β 78 specific rules for writing better Java code (read after getting comfortable with basics)
- Java: The Complete Reference by Herbert Schildt β Comprehensive desk reference for the full API
Practice Platforms
- LeetCode Java Solutions β Practice coding problems with Java
- HackerRank Java Domain β Java coding challenges
- Exercism Java Track β Practice with automated feedback
Community and Staying Current
- Inside Java Blog β Oracleβs blog about Java features
- /r/java β Community discussions about Java
- Java Weekly Newsletter β Weekly Java news and articles
Category
Related Posts
Cybersecurity Fundamentals Roadmap
Build practical cybersecurity skills from core principles to networks, identity, cryptography, secure software, vulnerability handling, and incident response.
Object-Oriented Design & Design Patterns Roadmap
Learn object-oriented design from core modeling principles through SOLID, GRASP, GoF patterns, refactoring, and a practical design capstone.
React + TypeScript Fundamentals Roadmap
Learn React and TypeScript through accessible, tested interfaces, from JSX and typed components to state, forms, effects, and a complete project.