为什么在卷曲的支架后不需要分号? [英] Why semicolon is not required after a curled bracket?
本文介绍了为什么在卷曲的支架后不需要分号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道在声明(我正在谈论Java,C ++和类似语言)之后需要分号,但在卷曲括号之后不需要。为什么会这样?
I know that a semicolon is required after a statement (I'm talking about Java, C++, and similar languages), but is not required after a curled bracket. Why so?
if (a > b)
printf("hello!"); // semicolon is mandatory
if (a > b) {
printf("hello!");
} // semicolon is not required
这是什么原因?我的意思是,这背后的理论是什么?
What is the reason? I mean, what is the theory behind this?
推荐答案
因为花括号用于分组语句,但它们本身不是语句。
Because curly brackets are used for grouping statements, but they are not statements themselves.
这篇关于为什么在卷曲的支架后不需要分号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文