A Java statement is a minimal construct that can be executed. It describes an action and ends with a semicolon (;). We have seen many statements already. For example, here are three statements:
float f = 23.42f;
String sf = String.valueOf(f);
System.out.println(sf);
The first line is a declaration statement combined with an assignment statement. The second line is also a declaration statement combined with an assignment statement and method invocation statement. The third line is just a method invocation statement.
Here is the list of Java statement types:
- An empty statement that consists of only one symbol, ; (semicolon)
- A class or interface declaration statement (we will talk about this in Chapter 2, Java Object-Oriented Programming (OOP))
- A local variable declaration statement: int x;
- A synchronized statement: this is beyond the scope of this book
- An expression...