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

Variables

In computer science, we think of a variable as a storage location that holds a data value. In Java, a variable is introduced by declaring it to have a specific type. For example, consider the following statement:

String lastName;

It declares the variable lastName to have type String.

We can also initialize a variable with an explicit value when it is declared, like this:

double temperature = 98.6;

Here, we would think of a storage location named temperature that contains the value 98.6 and has type double.

Structured variables can also be declared and initialized in the same statement:

int[] a = {88, 11, 44, 77, 22};

This declares the variable a to have type int[] (array of ints) and contain the five elements specified.

主站蜘蛛池模板: 荣成市| 临海市| 长沙市| 宣汉县| 基隆市| 黔东| 克拉玛依市| 南汇区| 绥棱县| 西和县| 镇巴县| 宜丰县| 依安县| 宽甸| 和平县| 聂荣县| 东乌珠穆沁旗| 滨海县| 龙江县| 全州县| 漯河市| 鹤壁市| 高邮市| 收藏| 新晃| 云南省| 沅陵县| 仁布县| 锡林郭勒盟| 宿州市| 广宗县| 平陆县| 观塘区| 南乐县| 前郭尔| 南木林县| 永吉县| 黄平县| 安新县| 沙坪坝区| 巴中市|