← Java tutorial

Java

Introduction to Java

Java is a statically-typed language, every variable's type is fixed and checked before the program even runs, catching a whole category of mistakes before your code ever executes, not while it's running.

Example: the minimum a Java program needs

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}
Hello, world!

Every Java program lives inside at least one class, and execution starts from a special main method, unlike Python or JavaScript, there's no way to run a bare line of code outside a class at all. This ceremony exists because Java is fundamentally class-based: even "hello world" has to live somewhere, and that somewhere is always a class.

Example
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}
Output
Hello, world!
Ready to go further?

These free tutorials are a preview, our Backend Development cohort covers it in depth, with a real project and a cohort alongside you. Closes Nov 30

Enroll in Backend Development

Cookie preferences

Choose what you're comfortable with. You can change this any time from the footer.

Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account