This is Module 1: Java.
We are going to build this out in a way that feels like a professional
textbook but reads like a conversation with a mentor.
As of March 2026, the world has moved to Java 25 (LTS) and the brand-new Java 26. We
won't just learn "old Java"; we’ll learn the modern way.
Part 1: The Modern Java Setup (2026)
In the old days, you had to write a massive "Class" just to print "Hello World." In 2026, we
use Compact Source Files.
The "New" Hello World
You no longer need public class Main or String[] args for simple scripts.
Java
// Save as [Link]
void main() {
[Link]("Welcome to Java 2026!");
}
• JDK 25/26: You can run this directly with java [Link]. No manual
compilation required for single files.
Part 2: Data & Variables (The Statically
Typed Strength)
Java is "Strict." If you say something is a number, it stays a number. This prevents 90% of
the bugs found in languages like JavaScript.
2.1 Primitives vs. Objects
• Primitives: Fast, simple values stored on the "Stack" (e.g., int, double, boolean).
• Reference Types: Complex objects stored on the "Heap" (e.g., String,
ArrayList, or your own custom User object).
2.2 Modern Pattern Matching (New in 2026)
One of the biggest updates in Java 26 is Primitive Types in Patterns. You can now use
instanceof and switch directly with primitives to write cleaner logic.
Java
Object value = 42;
if (value instanceof int i && i > 0) {
[Link]("It's a positive integer: " + i);
}
Part 3: The Object-Oriented Pillars (The
Core)
Java is built on "Objects." To understand objects, you must understand the Four Pillars.
1. Encapsulation (The "Black Box")
Keep your data safe. Use private variables and provide public getters/setters.
• Analogy: You use a TV remote (interface) without touching the internal wiring (data).
2. Inheritance (The "Family Tree")
Reuse code. A Tesla class can "extend" a Car class.
Java
class Car {
void drive() { [Link]("Moving..."); }
}
class Tesla extends Car {
void autoPilot() { [Link]("Self-driving..."); }
}
3. Polymorphism (The "Shape-Shifter")
"Many forms." A List can be an ArrayList or a LinkedList. The code doesn't care; it
just knows it's a list.
4. Abstraction (The "Blueprint")
Focus on what an object does, not how. We use Interfaces for this.
Java
interface Playable {
void play(); // No body, just a promise to have this method.
}
Part 4: Modern Features You Need to Know
4.1 Records (Data Carriers)
If you just need a class to hold data (like a User or Product), don't write a 50-line class. Use
a Record.
Java
public record User(String name, int age) {}
// That's it! Java automatically creates the constructor, getters, and
toString().
4.2 Virtual Threads (Project Loom)
In 2026, Java is the king of high-performance servers. Virtual Threads allow you to run
millions of simultaneous tasks (like handling web requests) without crashing your
computer's memory.
Part 5: Errors & The Collections Framework
5.1 Exception Handling
Never let your app crash. Surround risky code with try-catch.
Java
try {
int data = 10 / 0;
} catch (ArithmeticException e) {
[Link]("Math error: " + [Link]());
}
5.2 Collections (The Data Buckets)
• ArrayList: Your go-to for lists.
• HashMap: For Key-Value pairs (e.g., UserID -> UserName).
• HashSet: When you want to ensure every item is unique.
🎓 Java 2026 Quick-Start Summary
1. Install JDK 25 (LTS) for the most stable experience.
2. Use Records for simple data classes.
3. Use Var (var name = "Alex") when the type is obvious to keep code clean.
4. Embrace Streams for processing data: [Link]().filter(x -> x >
10).collect(toList());
What's our next move?
We can now:
1. Move to Module 2: JavaScript (The frontend power).
2. Stay on Java and build a "Mini Project" (like a simple Bank System or Student
Manager).
3. Deep-dive into Spring Boot (How real companies use Java to build websites).
Which do you prefer?