Note the use of variables:
After the variable definition can not be assigned, and then use the assignment. No assignment can not be used .
public static void main(String[] args) {
int x;
x = 20; // to x Assignment 20
System.out.println (x); // read the x value of the variable, and then printing
}
Limited scope when the variables:
public static void main(String[] args) {
int x = 20;
{
int y = 20;
}
System.out.println (x); // read the x value of the variable, and then printing
System.out.println (y); // read the y value of the variable in failure, cause of failure can not find the y variable, because beyond the y variable scope, can not be used y variables
}
Variable definitions can not be repeated:
public static void main(String[] args){
int x = 10;
double x = 5.5; // compilation fails, repetition variables defined
}
Data type conversion:
A small range of values of data types (e.g., byte ), can be directly converted to a wide range of types of data values (e.g., int );
A large range of values of the data type (e.g., int ), can not be directly converted to a small range of values of the data type (e.g. byte )
byte -> short -> int -> long -> float -> double
Only of those six to data conversion.
About data type conversion in two ways:
1.
Automatic type conversion
Converting data types represent small range of data types to be larger, this is called automatic conversion
Automatic conversion format:
A wide range of types of data variable = value of the small range of data types;
E.g:
double d = 1000;
or
int i = 100;
double d2 = i;
l system type conversion
Converting the data type represents a large range to a small range of data types, this is called a cast
Cast formats:
Small data type variable = ( small data types ) large range of data type value ;
E.g:
Operator: