+ 11
what do curly parentheses do in this case
this is a challenge code when I remove the parentheses , an error will happen https://code.sololearn.com/cc15dKL2G35r/?ref=app
10 Respostas
+ 21
The construct '{}' is a compound statement. The compound statement can contain zero or more arbitrary statement.
Thus, { { } }, which is a compound statement containing one statement which is a compound statement containing no statement, is legal.
• https://www.sololearn.com/Discuss/1020908/?ref=app
+ 19
ABADA S
You are welcome! 😊
Also, this is an exam question.
+ 19
Sonic
One of the questions from the Java SE7 test.
A compound statement is a sequence of zero or more statements enclosed in {...}.
It is considered to be a single statement.
A compound statement is a context. Any variables that are created inside the compound statement are destroyed at the end of it.
+ 7
I think the curly parentheses define a static initialisation block. The error when you remove these maybe because the statements are then not inside any constructor or method and therefore not allowed.
+ 6
Danijel Ivanović I think your answer agree with Sonic answer thank you
+ 5
thanks Sonic your answer is logical
when any object is created it will execute this parentheses at the first then call the constructor isn't it?
+ 5
Danijel Ivanović which exam? 😃
+ 1
My point of view inside curly parentheses this block is called Non Static block.
When we remove curly brace this two variables become instance variable but type is not define so error will come. If we declare type also error will remove.