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

3.2 Primitive Types

Let us make a couple quick notes about a couple of the data types as shown in table 3.1 before we continue. The char type is a Unicode character in Java, rather than an ASCII character, as most people are used to seeing. That means that any character (regardless of language) can be represented with a char variable. That’s why a char variable requires 2 bytes of storage rather than the 1 byte that is required for all ASCII characters. Also, you’ll notice in the sample initialization of the float variable the extra ‘f’ character. This is required because, by default, the Java compiler views all decimal literals as doubles. In order to place a double into a float, you need to do a cast. I’ll look at the reason for this next.

Java中字符類型屬于unicode編碼,每個(gè)字符占據(jù)2字節(jié)的存儲(chǔ)空間。

Table 3.1 Main primitive types in Java

主站蜘蛛池模板: 新丰县| 平远县| 江永县| 宣武区| 曲水县| 修水县| 蒲城县| 迁西县| 张家界市| 桦川县| 镇远县| 平泉县| 宁远县| 渭南市| 西盟| 齐河县| 湘乡市| 郯城县| 旌德县| 监利县| 小金县| 正宁县| 湟源县| 遵义市| 沧源| 永登县| 深州市| 盐山县| 临西县| 麟游县| 富民县| 金堂县| 福建省| 鄱阳县| 屏东县| 香格里拉县| 呼伦贝尔市| 榆树市| 苏尼特左旗| 佳木斯市| 安溪县|