现在的位置: 首页 > 综合 > 正文

Data Structure(1)

2014年03月03日 ⁄ 综合 ⁄ 共 1360字 ⁄ 字号 评论关闭

 

Data Structure

A literal numeric constant contains digits and an optional sign that indicates whether the constant is positive or negative. Floating-point constants also contain a decimal point. In the new Java 7, an int or long can contain underscores to improve readability.
For example, you can write the value one million as either 1000000 or 1_000_000.

Java is a strongly typed language, one in which all variables must be declared before they can be used.

 

(1).A variable is a named memory location that you can use to store a value; it can hold only one value at a time, but the value it holds can change.

(2).An item’s data type determines what legal identifiers can be used to describe variables and whether the variables can occupy memory.

(3).A variable declaration is a statement that reservers a named memory location and includes a data type, an identifier, an optional assignment operator and assigned value, and an ending semicolon.

 

In Java, you can use variables of types byte,short,int and long to store(or hold) intergers; an integers is a whole number without decimal places.

The types byte,short, and long are all variations of the integer type. The byte and short types occupy less memory and can hold only smaller values; the long type occupies more memory and can hold larger values.

 

It is important to choose appropriate types for the variables you will use in an application. If you attempt to assign a value that is too large for the data type of the variable, the compiler issues an error message and the application does not execute.
If you choose a data type that is larger than you need, you waste memory.

抱歉!评论已关闭.