- Java 9 Programming By Example
- Peter Verhas
- 147字
- 2021-07-02 23:37:32
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.
推薦閱讀
- 從零構(gòu)建知識圖譜:技術(shù)、方法與案例
- Apache Hive Essentials
- Python面向?qū)ο缶幊蹋簶?gòu)建游戲和GUI
- 數(shù)據(jù)結(jié)構(gòu)習(xí)題解析與實驗指導(dǎo)
- Mastering Business Intelligence with MicroStrategy
- Learning jQuery(Fourth Edition)
- Java編程從入門到精通
- C語言程序設(shè)計
- 物聯(lián)網(wǎng)系統(tǒng)架構(gòu)設(shè)計與邊緣計算(原書第2版)
- ASP.NET本質(zhì)論
- Java核心技術(shù)速學(xué)版(第3版)
- jMonkeyEngine 3.0 Beginner’s Guide
- 生成藝術(shù):Processing視覺創(chuàng)意入門
- C語言程序設(shè)計實驗指導(dǎo)教程
- SAP HANA Starter