In this lesson, we’ve started writing our first programs in Java.

We’ve also learned rules and guidelines for how to write Java programs:

  • Java programs have at least one class and one main() method.
    • Each class represents one real-world idea.
    • The main() method runs the tasks of the program.
  • Java comments add helpful context to human readers.
  • Java has whitespace, curly braces, and semicolons.
    • Whitespace is for humans to read code easily.
    • Curly braces mark the scope of a class and method.
    • Semicolons mark the end of a statement.
  • Java is a compiled language.
    • Compiling catches mistakes in our code.
    • Compilers transform code into an executable class.



The text editor holds an empty file named Review.java. Fill it in!

Define a public class named Review.

Use opening and closing curly braces for the scope of the class.

Remember, no semicolons for classes or methods!


This code produces an error because Java programs need a main() method.

Define the main() method within the curly braces of the Review class.


Inside of the curly braces for the main() method, write The main method executes the tasks of the class as a single-line comment.


Below the comment, write a statement that prints the following: My first Java program from scratch!.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?