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
- Each class represents one real-world idea.
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!
public class named
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 within the curly braces of the
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!.