Variables and Constants

Disclaimer: The materials used in this column are written by VIP students of Kaige Academy. Students have the right to remain anonymous and have the right to final interpretation of the article. Kaige Academy aims to promote VIP students to learn from each other based on public notes.

1. Variables

1. You can modify the data stored in it through the logo;
2. Application format: data type name; as shown in the figure:

image

image

Remember that assignment means overwriting, which will overwrite the value inside; for example:
//assignment means overwriting= means overwriting the old value int age=100;
age=90;
age=70;
age=10;
//the final value of age is 10 int age=100;
System.out.println(age);
age=90;
System.out.println(age);
age=70;
System.out.println(age);
age=10;
System.out.println (age);
3. Input name requirements: the preceding letters are lowercase;
4. Apply for a storage space of a data type to the memory, and the contiguous byte memory of the corresponding bytes of the data type will be allocated, as shown in the figure:

image

two. Constant
1. The identifier can be set to point to a data for the first time, and cannot be modified later;
2. Application format: final data type name;
such as: final int AGE=100; //AGE=10; quadratic value final float FF;
FF=10.5F;
final int AGE=100;
final float FF;
FF=10.5F;
final byte A,B,C,D,E,F;
A=65;
B=10;
C =89;
E=100;
F=-120;

3. The constant does not need to be given a value when applying, but it can be given before use, but remember that it can only be given once;
4. Input name requirements: it must be all uppercase;
5. The constant name usually points to a memory address, as shown in the figure:

image

three. Matters needing attention: 1. Whether it is a variable or a constant, it is just an identification symbol, and this identification symbol will point to a memory address;

image

2. No matter what the name is named, it starts with a letter or underscore, and can end with a number;
3. The same name cannot be applied for within the same area (within a curly bracket);
4. Values ​​also have types: after some values ​​are assigned to data types Incompatible, the assignment format is different; ①Integer
int ; ②Decimal
double;
③'' char;
④"" String;
⑤true|false boolean; The
decimal type
⑦ long cannot accept long integers within its own range, because all integers are of type int, and the int type can be up to 2.1 billion;

As shown in the figure:

image

5. Common data types: byte int double boolean.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326741852&siteId=291194637