官术网_书友最值得收藏!

Blocks

The code in Java is created in code blocks. Anything that is between the { and } characters is a block. In the preceding example, the code of the method is a block. It contains commands, and some of them, like the while loop, also contain a block. Inside that block, there are two commands. One of them is a for loop, again with a block. Although we can have single expressions to form the body of a loop, we usually use blocks. We will discuss loops in detail in just a few pages.

As we could see in the preceding example, the loops can be nested, and thus the { and } characters form pairs. A block can be inside another block, but two blocks cannot overlap. When the code contains a } character, it is closing the block that was opened last.

主站蜘蛛池模板: 四子王旗| 厦门市| 玉田县| 延寿县| 天津市| 广汉市| 连南| 岳阳县| 响水县| 沾益县| 孝义市| 封丘县| 灵武市| 洞头县| 炎陵县| 奉节县| 皮山县| 大厂| 兰西县| 新兴县| 扎囊县| 那坡县| 南召县| 镇康县| 平湖市| 鄂尔多斯市| 英德市| 祁东县| 丹阳市| 南投县| 吉木萨尔县| 南和县| 兴和县| 镇远县| 淳化县| 东阿县| 阳原县| 叙永县| 忻州市| 安平县| 松潘县|