How to define the language of a variable in 1.java
Data type variable name;
2. How to assign a value language to a variable
Variable name = value;
3. What is the nature of the variable,
The essence is a piece of space in memory, this space has ' type ', ' name ', ' value '
int a;//a space in memory, the type of this space is int
a=100;
System.out.println (a);//access The block of memory by variable name
System.out.println (a);//Repeat Access
4
public class vartest{
public static void Mian (string[] args) {
int i=10;//Applies a space of type int, named I, and assigns a value of 10;
System.out.println (i);
Re-assign Value
i=100;
System.out.println (i);
Variables can be re-assigned, but cannot be declared repeatedly,
In the same domain, variable names cannot be duplicated;
write int i=200; it's wrong.
Variables in the Java language must be declared before they are assigned to use the
int A;
System.out.println (a);//It would be an error to write.
Note: Int i1,i2,i3=23;//declares three variables i1,i2,i3, type is int type, I1,I2 two variables are not assigned, only i3 variable is assigned, I1,I2, no assignment, i.e. not initialized so it cannot be accessed.
}
public static void Main ()
int i=200;
Not in the same domain China can be declared with the same variable name
}
4.java variables