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

2.6 White Space

The first rule we present is a rule that does not result in any tokens or larger language structures. White space in Java refers to the space character (what you get when you type the space bar on the keyboard), the tab character (this is actually one character although it may appear as several spaces on your screen) and the new line character (what you get when you type the return or enter key on the keyboard). White space is used primarily to make the program look nice and also serves to separate adjacent, multi-character tokens that are not separated by any other punctuation(標點符號)and would otherwise be considered a single, longer token.

For example, white space is used to separate the words (tokens) public static void that we saw in example. In such situations, where one white space character is required, any number of white space characters can be used. We could have, for example, put each of the words public, static and void on separate lines or put lots of spaces between them like this:

public static void main(...

Except with String literals discussed below, any number of one or more adjacent white space characters (even mixing tab, space and newline) is the same as just one white space character as far as the structure and meaning of the program are concerned. Stated another way, if you can legally put in one space, you can put in as many spaces, tabs and newlines as you want. You cannot put white space in the middle of a keyword or identifier such as a variable or class name.

除了即將討論的String字符外,就程序的結構和意義而言,一個或多個相鄰的空格字符(即使混合的tab、空格和換行字符)等同于一個空格字符。

主站蜘蛛池模板: 隆德县| 连山| 彩票| 政和县| 横山县| 竹北市| 巴马| 门源| 宝鸡市| 瑞金市| 昭通市| 洪湖市| 上高县| 安福县| 闸北区| 乌兰县| 白玉县| 固阳县| 陆良县| 张家港市| 秦皇岛市| 邹平县| 伊宁县| 政和县| 阜城县| 洞头县| 平顶山市| 定日县| 林周县| 图木舒克市| 江津市| 望谟县| 健康| 常山县| 新田县| 蓬溪县| 墨脱县| 马山县| 施秉县| 漾濞| 洱源县|