Java Tutorial: Getting Started
Write your first Java program — understand the boilerplate, System.out.println, comments, and how Java compiles and runs.
The language that runs everywhere
Java is the backbone of Android apps, enterprise banking systems, and millions of backend services. It was designed with one goal: write once, run anywhere — and it still delivers on that promise 30 years later.
Unlike JavaScript or Python, Java requires a bit of structure upfront. But that structure is what makes large Java codebases maintainable — and what makes Java one of the most hireable skills in the world.
What you'll learn in this Java getting started tutorial
This interactive Java tutorial has 8 hands-on exercises. Estimated time: 15 minutes.
- Welcome to Java — Java runs on over 3 billion devices. Android phones, ATMs, airline booking systems — Java is everywhere.
- Print multiple lines — Each `System.out.println()` prints on its own line and adds a newline at the end.
- Comments — document your code — Java has three comment styles:
- String concatenation with + — In Java, `+` between strings joins them together:
- Arithmetic output — Java handles arithmetic directly inside `System.out.println`:
- Spot and fix the error — Java is compiled — syntax errors are caught before the program ever runs. This one has a missing semicolon and a wrong m…
- What is a class? — In Java, **everything lives inside a class**. The class named `Main` matches the filename `Main.java`.
- Write it from scratch — No starter code. Write everything yourself.
Java Getting Started concepts covered
- The language that runs everywhere