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

2.5 Lexical Elements

Java is a programming language and like any other language there are certain rules about how“words” in the language are formed and what constitutes a legal “sentence” in the language. In addition, Java has rules about how the sentences can be put together into a complete program, somewhat like the less formal rules about how to format a formal letter (e.g. with the address of the recipient, and opening salutation etc.) or how to structure a book (e.g. with chapters, a table of contents etc.). In this section we will begin by looking at the various “words” and symbols, called lexical elements, that are used to construct Java programs.

Java和其他程序語言一樣,有一些特定的語句規則,這些規則約束了哪些單詞可以使用,以及如何構成程序語言,這有點類似于寫一封規范的信(例如,收信人的稱呼、開場白等),或者是如何構建一本書(例如,篇章、目錄等)。

The most fundamental element in the structure of a program is a single character that can be displayed on a computer screen or typed at a computer keyboard. Prior to Java, most programming languages in common use during the last 10-20 years have used what is known as the ASCII character set. This character set provides for 256 different characters. This may seem like a lot, but when you consider all of the human languages in the world and the various symbols they use, it turns out that 256 is not enough. Therefore, Java has adopted what is called the Unicode character set. This set provides for more than 64,000 different characters.

When a Java compiler first begins to analyze a Java program it groups the individual characters together into larger lexical elements usually called tokens(符號). Some of the tokens will only be one character long such as the plus sign “+” which is the Java symbol used to add two numbers together(among other things). Other tokens will be many characters long such as the keywords like class and public. These basic tokens are then combined into larger language structures such as expressions, method calls, class definitions etc.

當Java編譯器開始分析Java程序時,它將各個字符集合在一起成為更大的元素,通常稱為符號。有些符號只有一個字符長,例如“+”在Java語言中將兩個數字加在一起。其他符號可以為多個字符,如關鍵詞class和public。

主站蜘蛛池模板: 浏阳市| 吉水县| 呈贡县| 镇雄县| 雅安市| 鄂州市| 襄汾县| 阜平县| 元谋县| 驻马店市| 浦江县| 吉木乃县| 百色市| 泽普县| 湖南省| 定日县| 河曲县| 临沭县| 松溪县| 泸州市| 江津市| 齐齐哈尔市| 台中市| 阿克陶县| 尚志市| 莱芜市| 渝中区| 勐海县| 安仁县| 云浮市| 石林| 西青区| 门头沟区| 宁南县| 习水县| 乐平市| 西峡县| 凤台县| 海伦市| 逊克县| 黄平县|