Structure of a Java Program

A beginner-friendly guide to class, main method, and curly braces.

Java Terms & Definitions

Term Definition
class A blueprint/container for Java code. Every Java file must have a class.
main method The starting point of a Java program. The JVM begins running code here.
statement A single instruction in Java (ends with a semicolon).
System.out.println() A command that prints text to the screen.
curly braces { } Used to group code into blocks (class blocks, method blocks).
JVM Java Virtual Machine. Runs the bytecode on your computer.
compiler (javac) Translates your .java code into .class bytecode so the JVM can run it.
variable A name that stores a value in memory. Example: int score = 10;
data type Tells Java what kind of data a variable will hold (int, double, boolean, String).
String A sequence of characters surrounded by double quotes.
boolean A true/false value.
method A block of code that performs a task. Can take parameters and return values.
parameter A variable listed inside a method’s parentheses. Example: doStuff(int x)
import Brings in code from Java libraries so you can use it. Example: import java.util.Scanner;
library (API) Collections of prewritten code you can use (Scanner, Math, Arrays, etc.).
semicolon ; Ends most Java statements.
comment Notes for humans inside code. Ignored by the computer. Example: // hello