Java - Block statement: { }
A compound statement is also known as block. to connect more than one statement in a statement, eventually reduces to a single command whole block of statements.{ }
Description
{}
{statement}
{statement statement}
Input
- statement - statements
Examples
Java
Block statement the possible of use:y=10;
if (x>1)
{
x=1;
y=y-1;
}
while (y>1)
{
x++;
y--;
}
Java
Other pieces of example codes:while (i<20) { i= i+2; if (i==16) { continue; } x++; }
if (i==10) break; else { i--; }
do { i++; if (i==5) break; } while ( i <10);
if (i > 10) { i =10; i = i - 1; i++; }
Block statement in another programming language:
Differences to: