Lesson 1 of 34

Your First Java Program

7 min 20 XP

Every Java program lives inside a class. The program starts running from the main() method. We show text on the screen with System.out.println(). Run the program below.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Every statement must end with a ; (semicolon). Text goes inside " " quotes and is called a String. The { } braces group code into blocks.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

println() moves to a new line after printing; print() stays on the same line. Java is case-sensitive: System and String always start with a capital S.

Challenge

+20 XP

Print these two lines exactly: Hello Java I can code!

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.