1, write the program is repeated in the memory access operation, the data into memory, when needed to take out the address to do processing.
2, variable is the most basic program of storage unit, is the memory allocated to the memory interval, for storing the corresponding data, through the variable name can access the relevant data inside.
3. Allocate memory space according to data type.
4. Variables must be initialized before they can be used;
5, int a=b=c=5; the wording of the company is wrong; int a=3,b=6,c=9; right;
6, cannot affirm the same name variable, the address is the unique identification;
7, the keyword can not be used as a variable name;
8. Variable names are case-sensitive.
9, Java Strong type language, for each kind of data has defined specific data types, in memory allocated a different size of memory space (platform-independent)
10, Jvmjava virtual machine to the memory management: when Java executes A class, the execution of the process to allocate memory frequently. Stack memory (some basic types declared in a method when a method is called), heap memory (new Object -- reference type), method area (some information about loading a class, static variables, constants), and so on.
11, accuracy problem -- beyond the range of data type; incompatible type - The assigned value is inconsistent with the data type defined by the variable.
public class DataDemo1
{
public static void Main (String [] args) {
BYTE age=20;
byte age=128; exceeds maximum range
Age=true; type not compatible
System.out.println (age);
Short number1=200;
int number2=100;
Long number3=2000;//automatically converted from int to long type
Long number3=2000l; the same effect
Long number3=2000l; the same effect
System.out.println (NUMBER1);
System.out.println (NUMBER2);
System.out.println (NUMBER3);
Float data1=10.5;10.5 is the double type by default.
float data1=10.5f;
Double data2=10.345;
Double data3=.344;
Double data4=0.3456e3;//scientific counting method 0.3456*10^3;
System.out.println (DATA1);
System.out.println (DATA2);
System.out.println (DATA3);
System.out.println (DATA4);
Boolean flag=true;
flag=1;//Data Type inconsistency
SYSTEM.OUT.PRINTLN (flag);
}
}
Java Foundation 2 (2015-8-3) variables and data types