← Learn to program
Phase 3 · Programming
Java from zero
9 lessons covering the Java basics a programming course needs, each showing the same idea in Python so you can connect the two.
Java needs a compiler (JDK) that doesn't run inside the browser in this version. So every example shows its real output, produced by actually compiling and running it with JDK 21, and the exercises are predict-the-output and complete-the-code. You can copy any example as a full program and run it on your computer.
Lessons
12 exercises22 exercises32 exercises42 exercises52 exercises62 exercises72 exercises82 exercises92 exercises
Your first Java program
class, main and System.out.println.
Variables and types
int, double, String and boolean.
Conditions and switch
if, else, switch and comparing strings.
Loops
for, while, break and continue.
Arrays and ArrayList
Fixed-size and growable collections.
Methods
Return types, parameters and void.
Classes and objects
Constructors, encapsulation and getters.
Inheritance and interfaces
extends, @Override and interface.
HashMap and exceptions
Key-value maps and try / catch.