give an example of a compound statement in Java programming
Answers
Answered by
42
In several places Java requires you to write one statement. But you might want to put several statements there instead of just one. You do that by packaging several statements up into a single statement, called a compound statement. Think of it as like putting a few things into a box and closing the box, so that it looks like just one thing, the box.
A compound statement begins with a left curly brace and ends with a right curly brace. In between, write any sequence of statements, one after another.
For example, compound statement
{
x = 1;
y = 0;
}
contains two smaller statements. The statements are done one after the other, from the beginning to the end.
You can put any number of statements inside the braces, including only one, or even none. Compound statement { } is a do-nothing statement.
A compound statement begins with a left curly brace and ends with a right curly brace. In between, write any sequence of statements, one after another.
For example, compound statement
{
x = 1;
y = 0;
}
contains two smaller statements. The statements are done one after the other, from the beginning to the end.
You can put any number of statements inside the braces, including only one, or even none. Compound statement { } is a do-nothing statement.
dassristi2016:
Thanks
Answered by
3
You can see attachment
I hope it helps you
Have a nice day
Attachments:
Similar questions
English,
7 months ago
Math,
7 months ago
Social Sciences,
7 months ago
Business Studies,
1 year ago
India Languages,
1 year ago