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

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.

主站蜘蛛池模板: 永新县| 武强县| 巴东县| 临邑县| 麻江县| 中西区| 牡丹江市| 南郑县| 拜泉县| 新郑市| 平远县| 平江县| 和政县| 盐边县| 泸州市| 郓城县| 新余市| 金山区| 云阳县| 星子县| 南投市| 息烽县| 竹溪县| 阿尔山市| 阿克| 华蓥市| 金寨县| 西青区| 绵阳市| 武强县| 北流市| 乐平市| 尼玛县| 都江堰市| 于都县| 定边县| 安庆市| 清水县| 临沂市| 花垣县| 富平县|