Java basic data Types
variable
1. Variable is the variable quantity.
2. Constants are immutable quantities.
3. Literal: Java variables and constants stored in the specific data into the literal amount.
variable
Naming rules:
(1) The first letter is an English letter, a $ or an underscore, consisting of letters, numbers, and underscores.
(2) The name of the variable follows the principle of seeing the uprising.
(3) The Java variable name is not recommended in Chinese.
(4) The first letter of the variable name is not recommended for uppercase letters.
(5) The name of a variable named multiple words by means of the hump nomenclature.
(6) Variable name do not use the Java keyword.
Defined:
Each variable must belong to a data type.
Type variable name 1, variable 2, ..., variable n;
Example:
BYTE score;
Short age;
int Sumscore;
Long fileSize;
float X,y;
Double result;
Boolean OK;
string S;
Initialization of a variable
Variable name = value;
Example: OK = 1;
x=y=1;//Continuous Assignment
int ans=0;//Declaration and initialization
In Java, a pair of {} is a scope that does not allow the occurrence of a variable of the same name in the same scope.
(As with the case of different scopes is not covered in this section, see later articles.) )
Import java.io.*;
Import java.math.*;
public class test02 {public
static void Main (string[] args) {
//TODO auto-generated method Stub
String a = " 1 ";
String a = "2";
System.out.println (a);
}
The above code again defines a in the same scope after the string A is defined, and an error is made.
Of course, if you change the above code to
Import java.io.*;
Import java.math.*;
public class Test02 {
String a = "1";
public static void Main (string[] args) {
//TODO auto-generated method Stub
String a = "2";
System.out.println (a);
}
The program outputs 2;
Reprinted marked Source: http://blog.csdn.net/qq_33583069/article/details/50625502.