All lessons

Your First Program

6 min · Java

Write and run your very first Java program, right here on the page.

Java · Your First Program0/5 cleared

Enemy 1 of 5

Java code lives inside a class, and every program starts running from a special method called main. This is called the entry point, the exact spot where execution begins. Don't worry about understanding every word of the surrounding scaffolding yet (public, static, String[] args); focus on the one line in the middle that actually does something, and you'll learn what the rest means over the next few lessons.

Compared to Python or JavaScript, Java asks you to write more structure upfront (a class wrapper and a main method signature) before you can print anything. This is because Java is a fully object-oriented language: literally everything, even a program's starting point, has to live inside a class. It can feel like extra ceremony at first, but this same structure is what makes larger Java programs easier to organize once they grow.

System.out.println prints a message to the screen, then moves to a new line automatically (the ln stands for "line"). The text goes inside the parentheses and quotes, so Java treats it as literal text. Press Run.

You
Binary Treant

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: Hello, World!