different from
void.
NOTE
For methods having a void return type, this statement can be omitted and will be
implicitly added by the compiler.
Block Statements
A group of statements enclosed within curly braces comprises a block.
Thus, a block contains a
statement list—a sequence of statements.
A statement in a block is called an embedded statement
and it can be a label, a declaration, or a simple statement. Please note that a block is also called
a compound statement.
It is valid to have no statements or an empty statement in a block. A block is
syntactically similar to a single statement.
Also note that no semicolon is placed after the closing
brace that ends a block.
When there is no statement in a block, it is called an
empty block. A block
having an empty statement is not an empty block since it contains a valid statement.
That is,
{ } //is empty block
{ ; } //non-empty block
Empty statement: A statement that does nothing is known as an empty statement.
It is
written as a single semicolon as follows:
; //empty statement
Do'stlaringiz bilan baham: |