Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a block a statement in Java?

Tags:

java

This could apply to other languages but asking specific to Java. In Java would a block itself be a statement? In the Java tutorials: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/expressions.html a block is treated separately from a statement by saying it is a sequence/group of statements but does not say it is a statement itself. Can someone please also explain why.

like image 976
leronvane Avatar asked Mar 02 '23 20:03

leronvane


1 Answers

Yes, according to the grammar defined in the Java Language Specification (§14.5), a Block is a kind of Statement, specifically it is a StatementWithoutTrailingSubstatement.

like image 71
kaya3 Avatar answered Mar 15 '23 11:03

kaya3