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

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.

主站蜘蛛池模板: 延庆县| 星座| 虞城县| 肃宁县| 宜兰县| 灵川县| 沛县| 隆子县| 开化县| 西吉县| 浦城县| 大邑县| 汉川市| 武清区| 正阳县| 绥滨县| 屏山县| 汤原县| 通城县| 小金县| 海门市| 义乌市| 称多县| 哈密市| 元江| 大宁县| 永嘉县| 禹州市| 黄石市| 江北区| 长宁县| 巨野县| 黄冈市| 渝北区| 临清市| 延安市| 昌宁县| 苍山县| 山东省| 图们市| 安乡县|