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

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.

主站蜘蛛池模板: 黄龙县| 乐安县| 乌兰县| 天津市| 郸城县| 灵寿县| 华蓥市| 融水| 绥化市| 宜都市| 广南县| 任丘市| 靖江市| 云梦县| 霞浦县| 福清市| 涿州市| 乐清市| 新巴尔虎右旗| 资源县| 云阳县| 麻栗坡县| 马关县| 遂溪县| 德昌县| 上思县| 广饶县| 新巴尔虎右旗| 横峰县| 平凉市| 防城港市| 安岳县| 浠水县| 丽水市| 内丘县| 曲麻莱县| 莱芜市| 五寨县| 桂阳县| 霍城县| 鹰潭市|