Statements and Expressions
Computer programs are a set of instructions that tell the computer what to do. Each instruction is called a statement. The following example from a Java program is a statement:
int highScore = 450000;
You can use brackets to group a set of statements together in a Java program. These groupings are called block statements. Consider the following portion of a program:
1: public static void main(String[] args) {2: int a = 3;3: int b = 4;4: int c = 8 * 5;5: }
Lines 2–4 of this example are a block statement. The opening bracket on Line 1 denotes the beginning of the block, and the closing bracket on Line 5 denotes the end of the block.
Some statements are called expressions because they involve a mathematical expression ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access