Where Does One Statement End and the Next Begin?
A program in any programming language is made up of statements. One of issues confronting a programming language designer is, how does one tell where one statement ends and the next begins? There are three common approaches: statement terminators (used in C++ and Java), statement separators, and statement-per-line.
Most early programming languages, including FORTRAN, COBOL, and BASIC, took the statement-per-line approach. This made a lot of sense in the days before disk drives, when programs were stored in the form of decks of punched cards. Most of these languages had some gimmick for indicating that a statement was continued on the next line. Visual BASIC and Python continue to use the statement-per-line approach.
The second approach is to use some character, usually a semicolon, as a statement separator. The statement separator is then not a part of any statement. The language Pascal used the semicolon as a separator.
The third approach is to use some character, again usually a semicolon, as a statement terminator. The terminator character is then a part of the statement terminated. Java, C, C++, C#, JavaScript, Perl and several others use the semicolon as a statement terminator.
In Java, C, and related languages, there is one important exception to the rule that every statement ends in a semicolon: the compound statement, also known as a block. A compound statement is a sequence of statements enclosed in braces {...}. For example, {x = 1; y = 2;}. Can you find the single compound statement in HelloUMUC.java?