|
Each language will be designed to a lot of data, so you will come into contact with different data types, the initial contact data type is also faint, in the Java language, finally a little understand, comb,
The concept of a variable
A memory area in memory
Variable name + data type
Can vary within the same type of range
Why Define Variables:
Used to keep the same type of constant constant, and can be reused
Using variables Note:
The scope of the variable, a pair of {} between the effective
Initialize the value
Define the format of the variable:
Data type Variable name = Initialize value
Example: int x = 4
Note: The format is fixed
Understanding: Variables are like unknowns in mathematics.
type of data:
Integer The default type is int
The decimal default type is: double
Occupied memory and range of values
Integer
Occupied storage space (bytes)
Size range
Byte
1
-128-127
Short
2
-215 to 215-1
Int
4
-231 to 231-1
Long
8
-263 to 263-1
Floating point type
Float
4
-3.403E38 to 3.403E38
Double
8
-1.798E308 ~ 1.798E308
Character type
Char
2 (Unicode encoding)
Boolean type
Boolean
1 (actually 1 / 8byte)
Resolution: Why byte occupies a byte, the range is -128 ~ 127
First need to know that in binary, the most significant bit is the sign bit, 0 for positive, 1 for negative, other bits are data bits.
Byte total of 8 bits, said 256 (28).
The maximum value is 01111111, and the decimal value is 127
The minimum value is 10000000, 1 is the sign bit, representing a negative number, converted to decimal 128. So the minimum value is -128
Specifically why is -128? How are binary and decimal conversions at the bottom? Will be related to the original code, code, complement, and listen to the next chapter analysis.
summary:
In the final analysis, the most important software system is data, data is the core of the enterprise. Although some of the underlying things we do not need to master, but only to find out these later used to be handy, ripe! |
|
|
|